1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

When a role/include has a conditional, add that conditional ahead of any on the task, not behind, so it can short circuit.

This commit is contained in:
Michael DeHaan 2013-07-20 18:34:24 -04:00
parent 419661542b
commit bf70dfc1a0

View file

@ -294,9 +294,9 @@ class Play(object):
terms = template(self.basedir, x[k], task_vars) 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) items = utils.plugins.lookup_loader.get(plugin_name, basedir=self.basedir, runner=None).run(terms, inject=task_vars)
elif k.startswith("when_"): 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': 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"): elif k in ("include", "vars", "only_if", "sudo", "sudo_user"):
pass pass
else: else: