{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/19154","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/19154/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/19154/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/19154/events","html_url":"https://github.com/ansible/ansible/issues/19154","id":194767197,"number":19154,"title":"Template module does not adhere to variable precedence","user":{"login":"ashemedai","id":610865,"avatar_url":"https://avatars.githubusercontent.com/u/610865?v=3","gravatar_id":"","url":"https://api.github.com/users/ashemedai","html_url":"https://github.com/ashemedai","followers_url":"https://api.github.com/users/ashemedai/followers","following_url":"https://api.github.com/users/ashemedai/following{/other_user}","gists_url":"https://api.github.com/users/ashemedai/gists{/gist_id}","starred_url":"https://api.github.com/users/ashemedai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashemedai/subscriptions","organizations_url":"https://api.github.com/users/ashemedai/orgs","repos_url":"https://api.github.com/users/ashemedai/repos","events_url":"https://api.github.com/users/ashemedai/events{/privacy}","received_events_url":"https://api.github.com/users/ashemedai/received_events","type":"User","site_admin":false},"labels":[{"id":437720699,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.2","name":"affects_2.2","color":"5319e7","default":false},{"id":48276055,"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04","default":false},{"id":496359346,"url":"https://api.github.com/repos/ansible/ansible/labels/module","name":"module","color":"1d76db","default":false},{"id":88746767,"url":"https://api.github.com/repos/ansible/ansible/labels/plugin","name":"plugin","color":"bfe5bf","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-10T13:24:00Z","updated_at":"2016-12-20T16:40:08Z","closed_at":null,"body":"_Copied from original issue: ansible/ansible-modules-core#5868_\r\n\r\n<!--- Verify first that your issue/request is not already reported in GitHub -->\r\n\r\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\ntemplate\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\r\n```\r\nansible 2.2.0.0\r\n  config file = \r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### CONFIGURATION\r\n<!---\r\nMention any settings you have changed/added/removed in ansible.cfg\r\n(or using the ANSIBLE_* environment variables).\r\n-->\r\n\r\nNo settings in place.\r\n\r\n##### OS / ENVIRONMENT\r\n<!---\r\nMention the OS you are running Ansible from, and the OS you are\r\nmanaging, or say “N/A” for anything that is not platform-specific.\r\n-->\r\n\r\nN/A\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly -->\r\n\r\n##### STEPS TO REPRODUCE\r\n<!---\r\nFor bugs, show exactly how to reproduce the problem.\r\nFor new features, show how the feature would be used.\r\n-->\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n\r\nPlease replace - in filename with /\r\nhttps://gist.github.com/ashemedai/6482b3fdb8a64eed14c44554f1898893\r\n\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- What did you expect to happen when running the steps above? -->\r\n\r\nThe file test.output to contain: Variable in question: \"Ijklmnop\"\r\n\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->\r\n\r\nThe file test.output contains: Variable in question: \"Abcdefgh\"\r\n\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\n% ansible-playbook -vvvv testplaybook -i inventory/testenv\r\nNo config file found; using defaults\r\nLoading callback plugin default of type stdout, v2.0 from /usr/local/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pyc\r\n\r\nPLAYBOOK: testplaybook *********************************************************\r\n1 plays in testplaybook\r\n\r\nPLAY [Testing variables] *******************************************************\r\n\r\nTASK [testrole : debug] ********************************************************\r\ntask path: /home/jeroenr/ansible/testrole/tasks/main.yml:1\r\nok: [localhost] => {\r\n    \"testvar1\": \"Abcdefgh\"\r\n}\r\n\r\nTASK [testrole : debug] ********************************************************\r\ntask path: /home/jeroenr/ansible/testrole/tasks/main.yml:4\r\nok: [localhost] => {\r\n    \"testvar2\": \"Ijklmnop\"\r\n}\r\n\r\nTASK [testrole : debug] ********************************************************\r\ntask path: /home/jeroenr/ansible/testrole/tasks/main.yml:7\r\nok: [localhost] => {\r\n    \"setting\": \"Abcdefgh\"\r\n}\r\n\r\nTASK [testrole : debug] ********************************************************\r\ntask path: /home/jeroenr/ansible/testrole/tasks/main.yml:10\r\nok: [localhost] => {\r\n    \"apache_vhosts\": [\r\n        {\r\n            \"setting\": \"Ijklmnop\"\r\n        }\r\n    ]\r\n}\r\n\r\nTASK [testrole : Test template] ************************************************\r\ntask path: /home/jeroenr/ansible/testrole/tasks/main.yml:13\r\n<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: jeroenr\r\n<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601 `\" && echo ansible-tmp-1481288820.47-185974184970601=\"` echo $HOME/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601 `\" ) && sleep 0'\r\nUsing module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/files/stat.py\r\n<127.0.0.1> PUT /tmp/tmpBZata5 TO /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/stat.py\r\n<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/ /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/stat.py && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/stat.py && sleep 0'\r\n<127.0.0.1> PUT /tmp/tmpwTMm8B TO /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/source\r\n<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/ /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/source && sleep 0'\r\nUsing module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/files/copy.py\r\n<127.0.0.1> PUT /tmp/tmpsb1ndq TO /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/copy.py\r\n<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/ /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/copy.py && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/copy.py && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/ > /dev/null 2>&1 && sleep 0'\r\nchanged: [localhost -> 127.0.0.1] => (item={u'setting': u'Ijklmnop'}) => {\r\n    \"changed\": true, \r\n    \"checksum\": \"0000a8d305bfb42e85bccb5f9ed6702e2cea4ae9\", \r\n    \"dest\": \"/tmp/test.output\", \r\n    \"gid\": 1000, \r\n    \"group\": \"jeroenr\", \r\n    \"invocation\": {\r\n        \"module_args\": {\r\n            \"backup\": false, \r\n            \"content\": null, \r\n            \"delimiter\": null, \r\n            \"dest\": \"/tmp/test.output\", \r\n            \"directory_mode\": null, \r\n            \"follow\": true, \r\n            \"force\": true, \r\n            \"group\": null, \r\n            \"mode\": null, \r\n            \"original_basename\": \"test.j2\", \r\n            \"owner\": null, \r\n            \"regexp\": null, \r\n            \"remote_src\": null, \r\n            \"selevel\": null, \r\n            \"serole\": null, \r\n            \"setype\": null, \r\n            \"seuser\": null, \r\n            \"src\": \"/home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/source\", \r\n            \"unsafe_writes\": null, \r\n            \"validate\": null\r\n        }\r\n    }, \r\n    \"item\": {\r\n        \"setting\": \"Ijklmnop\"\r\n    }, \r\n    \"md5sum\": \"7ff832456b67b6778d49dc5e33e78b70\", \r\n    \"mode\": \"0644\", \r\n    \"owner\": \"jeroenr\", \r\n    \"size\": 85, \r\n    \"src\": \"/home/jeroenr/.ansible/tmp/ansible-tmp-1481288820.47-185974184970601/source\", \r\n    \"state\": \"file\", \r\n    \"uid\": 1000\r\n}\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=5    changed=1    unreachable=0    failed=0   \r\n\r\n% cat /tmp/test.output \r\nSimply testing variable precedence and expansion:\r\n\r\nVariable in question: \"Abcdefgh\"\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/268292079","html_url":"https://github.com/ansible/ansible/issues/19154#issuecomment-268292079","issue_url":"https://api.github.com/repos/ansible/ansible/issues/19154","id":268292079,"user":{"login":"ashemedai","id":610865,"avatar_url":"https://avatars.githubusercontent.com/u/610865?v=3","gravatar_id":"","url":"https://api.github.com/users/ashemedai","html_url":"https://github.com/ashemedai","followers_url":"https://api.github.com/users/ashemedai/followers","following_url":"https://api.github.com/users/ashemedai/following{/other_user}","gists_url":"https://api.github.com/users/ashemedai/gists{/gist_id}","starred_url":"https://api.github.com/users/ashemedai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashemedai/subscriptions","organizations_url":"https://api.github.com/users/ashemedai/orgs","repos_url":"https://api.github.com/users/ashemedai/repos","events_url":"https://api.github.com/users/ashemedai/events{/privacy}","received_events_url":"https://api.github.com/users/ashemedai/received_events","type":"User","site_admin":false},"created_at":"2016-12-20T16:40:08Z","updated_at":"2016-12-20T16:40:08Z","body":"Discussion with @bcoca on IRC informed me that it cannot be the template module due to the fact that the variables have been flattened before handed over to the template module. As such it's should be found in the core engine. I need to revisit my test case to not depend on the template module."}}
{"actor":{"display_login":"ashemedai"}}