From 14db2fa376e8b4bc9adb96d1def9a5b485f8fb3d Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Wed, 5 Sep 2012 23:18:47 +0200 Subject: [PATCH] Add an isset("$var") function to only_if --- lib/ansible/runner/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 61b191171f..f5ae5d8e8f 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -538,8 +538,12 @@ class Runner(object): self.module_args = new_args self.module_args = utils.template(self.module_args, inject) + def _check_conditional(conditional): + def isset(var): + return not var.startswith("$") + return eval(conditional) conditional = utils.template(self.conditional, inject) - if not eval(conditional): + if not _check_conditional(conditional): result = utils.jsonify(dict(skipped=True)) self.callbacks.on_skipped(host, inject.get('item',None)) return ReturnData(host=host, result=result)