-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug show VARIABLE IS NOT DEFINED on variable when content is the same as name variable #13453
Comments
The following patch is doing the job: diff --git a/lib/ansible/plugins/action/debug.py b/lib/ansible/plugins/action/debug.py
index a024e28..1d8e28c 100644
--- a/lib/ansible/plugins/action/debug.py
+++ b/lib/ansible/plugins/action/debug.py
@@ -45,8 +45,12 @@ class ActionModule(ActionBase):
# If var is a list or dict, use the type as key to display
result[to_unicode(type(self._task.args['var']))] = results
else:
+ # If var name is same as result, try to template it
if results == self._task.args['var']:
- results = "VARIABLE IS NOT DEFINED!"
+ try:
+ results = self._templar.template("{{" + results + "}}", convert_bare=True, fail_on_undefined=True)
+ except:
+ results = "VARIABLE IS NOT DEFINED!"
result[self._task.args['var']] = results
else:
result['msg'] = 'here we are' Here is a simple example:
ansible -m debug -a var=test localhost
localhost | SUCCESS => {
"changed": false,
"test": "VARIABLE IS NOT DEFINED!"
}
ansible -m debug -a var=test -e test=test localhost
localhost | SUCCESS => {
"changed": false,
"test": "test"
} |
Yannig
added a commit
to Yannig/ansible
that referenced
this issue
Dec 7, 2015
See ansible#13453 for more details.
Merged your patch above, so closing this. Thanks! |
This issue is here again in last devel. I'll publish a new PR. |
ghost
mentioned this issue
May 16, 2018
I see this problem in 2.4.5.0 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Issue Type: Bug Report
Ansible Version: last devel
Ansible Configuration: nothing special
Environment: nothing special
Summary:
Ansible show VARIABLE IS NOT DEFINED on variable when content is the same as name variable
Steps To Reproduce:
An easy way to reproduce this behaviour is to launch the following test:
Expected Results:
Actual Results:
The text was updated successfully, but these errors were encountered: