mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Change conditional operation workflow.
Conflicts: lib/ansible/utils/__init__.py
This commit is contained in:
parent
7f462a346a
commit
0756aa406a
1 changed files with 8 additions and 2 deletions
|
@ -162,11 +162,17 @@ def check_conditional(conditional, basedir, inject, fail_on_undefined=False):
|
|||
# allow variable names
|
||||
if conditional in inject:
|
||||
conditional = inject[conditional]
|
||||
print "INJECTIFYING: %s" % inject
|
||||
conditional = template.template(basedir, conditional, inject, fail_on_undefined=fail_on_undefined)
|
||||
# a Jinja2 evaluation that results in something Python can eval!
|
||||
presented = "{% if " + conditional + " %} True {% else %} False {% endif %}"
|
||||
return presented
|
||||
conditional = template.template(basedir, presented, inject)
|
||||
val = conditional.lstrip().rstrip()
|
||||
if val == "True":
|
||||
return True
|
||||
elif val == "False":
|
||||
return False
|
||||
else:
|
||||
raise errors.AnsibleError("unable to evaluate conditional: %s" % conditional)
|
||||
|
||||
if not isinstance(conditional, basestring):
|
||||
return conditional
|
||||
|
|
Loading…
Reference in a new issue