From d2721526de60c2c3359842180703b625fdead82f Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 19 Jun 2013 21:17:39 -0400 Subject: [PATCH] Small tweak, don't merge conditionals, just evaluate each in turn. --- lib/ansible/playbook/task.py | 3 ++- lib/ansible/runner/__init__.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index ac9972fc59..7a34601c7e 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -230,5 +230,6 @@ class Task(object): self.only_if = utils.compile_when_to_only_if(self.when) if additional_conditions: - self.only_if = '(' + self.only_if + ') and (' + ' ) and ('.join(additional_conditions) + ')' + self.only_if = [ self.only_if ] + self.only_if.extend(additional_conditions) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 259c18b82b..e1d8cc8c2a 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -504,12 +504,15 @@ class Runner(object): else: handler = utils.plugins.action_loader.get('async', self) - conditional = template.template(self.basedir, self.conditional, inject, expand_lists=False) + if type(self.conditional) != list: + self.conditional = [ self.conditional ] - if not utils.check_conditional(conditional): - result = utils.jsonify(dict(changed=False, skipped=True)) - self.callbacks.on_skipped(host, inject.get('item',None)) - return ReturnData(host=host, result=result) + for cond in self.conditional: + cond = template.template(self.basedir, cond, inject, expand_lists=False) + if not utils.check_conditional(cond): + result = utils.jsonify(dict(changed=False, skipped=True)) + self.callbacks.on_skipped(host, inject.get('item',None)) + return ReturnData(host=host, result=result) conn = None actual_host = inject.get('ansible_ssh_host', host)