mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
When var name is the same as var content, try to template it before reporting that var is not defined. (#13629)
* When var name is the same as var content, try to template it before reporting that var is not defined. Add asserts in test_var_blending to check this special corner case. * Fix integration tests when using debug with list or dict.
This commit is contained in:
@@ -54,7 +54,11 @@ class ActionModule(ActionBase):
|
||||
try:
|
||||
results = self._templar.template(self._task.args['var'], convert_bare=True, fail_on_undefined=True, bare_deprecated=False)
|
||||
if results == self._task.args['var']:
|
||||
raise AnsibleUndefinedVariable
|
||||
# if results is not str/unicode type, raise an exception
|
||||
if type(results) not in [str, unicode]:
|
||||
raise AnsibleUndefinedVariable
|
||||
# If var name is same as result, try to template it
|
||||
results = self._templar.template("{{" + results + "}}", convert_bare=True, fail_on_undefined=True)
|
||||
except AnsibleUndefinedVariable:
|
||||
results = "VARIABLE IS NOT DEFINED!"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user