From bf70dfc1a096ae7818616a4a6936f77f9c1c126d Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Sat, 20 Jul 2013 18:34:24 -0400 Subject: [PATCH] When a role/include has a conditional, add that conditional ahead of any on the task, not behind, so it can short circuit. --- lib/ansible/playbook/play.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index c539162778c..4e1bc4d0868 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -294,9 +294,9 @@ class Play(object): terms = template(self.basedir, x[k], task_vars) items = utils.plugins.lookup_loader.get(plugin_name, basedir=self.basedir, runner=None).run(terms, inject=task_vars) elif k.startswith("when_"): - included_additional_conditions.append(utils.compile_when_to_only_if("%s %s" % (k[5:], x[k]))) + included_additional_conditions.insert(0, utils.compile_when_to_only_if("%s %s" % (k[5:], x[k]))) elif k == 'when': - included_additional_conditions.append(utils.compile_when_to_only_if("jinja2_compare %s" % x[k])) + included_additional_conditions.insert(0, utils.compile_when_to_only_if("jinja2_compare %s" % x[k])) elif k in ("include", "vars", "only_if", "sudo", "sudo_user"): pass else: