{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/15044","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/15044/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/15044/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/15044/events","html_url":"https://github.com/ansible/ansible/issues/15044","id":141995942,"number":15044,"title":"add ansible_managed to template lookup plugin","user":{"login":"DavidWittman","id":714287,"avatar_url":"https://avatars0.githubusercontent.com/u/714287?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidWittman","html_url":"https://github.com/DavidWittman","followers_url":"https://api.github.com/users/DavidWittman/followers","following_url":"https://api.github.com/users/DavidWittman/following{/other_user}","gists_url":"https://api.github.com/users/DavidWittman/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidWittman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidWittman/subscriptions","organizations_url":"https://api.github.com/users/DavidWittman/orgs","repos_url":"https://api.github.com/users/DavidWittman/repos","events_url":"https://api.github.com/users/DavidWittman/events{/privacy}","received_events_url":"https://api.github.com/users/DavidWittman/received_events","type":"User","site_admin":false},"labels":[{"id":437720458,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.0","name":"affects_2.0","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":48457795,"url":"https://api.github.com/repos/ansible/ansible/labels/feature_idea","name":"feature_idea","color":"006b75","default":false},{"id":54811101,"url":"https://api.github.com/repos/ansible/ansible/labels/needs_info","name":"needs_info","color":"eb6420","default":false},{"id":572345061,"url":"https://api.github.com/repos/ansible/ansible/labels/needs_template","name":"needs_template","color":"f9d0c4","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-03-18T22:51:45Z","updated_at":"2017-04-13T15:03:13Z","closed_at":"2017-04-13T15:03:13Z","body":"##### Issue Type:\n- Bug Report\n##### Ansible Version:\n\n```\n$ ansible --version\nansible 2.0.1.0\n  config file =\n  configured module search path = Default w/o overrides\n```\n##### Ansible Configuration:\n\nN/A\n##### Environment:\n\nN/A\n##### Summary:\n\nThe variable `ansible_managed` is undefined when templating via the `template` lookup plugin.\n##### Steps To Reproduce:\n\nCreate a template with `{{ ansible_managed }}` in it, then try compiling the template with `lookup('template', 'path/to/template.j2')`.\n\n```\n- name: test ansible_managed in lookup template\n  hosts: localhost\n  connection: local\n  tasks:\n    - name: create template\n      copy:\n        dest: ./template_test.j2\n        content: |\n          TEST {% raw %}{{ ansible_managed }}{% endraw %} /TEST\n    - name: test template using template module\n      template:\n        src: ./template_test.j2\n        dest: ./template_test.out\n    - name: test template using template lookup plugin (this will fail)\n      debug: msg=\"{{ lookup('template', 'foo.j2') }}\"\n```\n##### Expected Results:\n\nI expect `ansible_managed` to exist when templating via the lookup plugin.\n##### Actual Results:\n\n`ansible_managed` is undefined.\n\n```\n$ ansible-playbook test.yml -i localhost,\n\nPLAY [test lookup template] ****************************************************\n\nTASK [setup] *******************************************************************\nok: [localhost]\n\nTASK [create template] *********************************************************\nchanged: [localhost]\n\nTASK [test template using template module] *************************************\nchanged: [localhost]\n\nTASK [test template using template lookup plugin (this will fail)] *************\nfatal: [localhost]: FAILED! => {\"failed\": true, \"msg\": \"'ansible_managed' is undefined\"}\n\nNO MORE HOSTS LEFT *************************************************************\n    to retry, use: --limit @test.retry\n\nPLAY RECAP *********************************************************************\nlocalhost                  : ok=3    changed=2    unreachable=0    failed=1\n```\n"}}
{"actor":{"display_login":"bcoca"}}