{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/17947","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/17947/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/17947/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/17947/events","html_url":"https://github.com/ansible/ansible/issues/17947","id":181836046,"number":17947,"title":"Default ansible_managed to a static string","user":{"login":"abadger","id":209242,"avatar_url":"https://avatars.githubusercontent.com/u/209242?v=3","gravatar_id":"","url":"https://api.github.com/users/abadger","html_url":"https://github.com/abadger","followers_url":"https://api.github.com/users/abadger/followers","following_url":"https://api.github.com/users/abadger/following{/other_user}","gists_url":"https://api.github.com/users/abadger/gists{/gist_id}","starred_url":"https://api.github.com/users/abadger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadger/subscriptions","organizations_url":"https://api.github.com/users/abadger/orgs","repos_url":"https://api.github.com/users/abadger/repos","events_url":"https://api.github.com/users/abadger/events{/privacy}","received_events_url":"https://api.github.com/users/abadger/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.1","name":"affects_2.1","color":"5319e7"},{"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.2","name":"affects_2.2","color":"5319e7"},{"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.3","name":"affects_2.3","color":"5319e7"},{"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04"},{"url":"https://api.github.com/repos/ansible/ansible/labels/docs_report","name":"docs_report","color":"0052cc"},{"url":"https://api.github.com/repos/ansible/ansible/labels/feature_idea","name":"feature_idea","color":"006b75"},{"url":"https://api.github.com/repos/ansible/ansible/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"closed","locked":false,"assignee":{"login":"abadger","id":209242,"avatar_url":"https://avatars.githubusercontent.com/u/209242?v=3","gravatar_id":"","url":"https://api.github.com/users/abadger","html_url":"https://github.com/abadger","followers_url":"https://api.github.com/users/abadger/followers","following_url":"https://api.github.com/users/abadger/following{/other_user}","gists_url":"https://api.github.com/users/abadger/gists{/gist_id}","starred_url":"https://api.github.com/users/abadger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadger/subscriptions","organizations_url":"https://api.github.com/users/abadger/orgs","repos_url":"https://api.github.com/users/abadger/repos","events_url":"https://api.github.com/users/abadger/events{/privacy}","received_events_url":"https://api.github.com/users/abadger/received_events","type":"User","site_admin":false},"assignees":[{"login":"abadger","id":209242,"avatar_url":"https://avatars.githubusercontent.com/u/209242?v=3","gravatar_id":"","url":"https://api.github.com/users/abadger","html_url":"https://github.com/abadger","followers_url":"https://api.github.com/users/abadger/followers","following_url":"https://api.github.com/users/abadger/following{/other_user}","gists_url":"https://api.github.com/users/abadger/gists{/gist_id}","starred_url":"https://api.github.com/users/abadger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadger/subscriptions","organizations_url":"https://api.github.com/users/abadger/orgs","repos_url":"https://api.github.com/users/abadger/repos","events_url":"https://api.github.com/users/abadger/events{/privacy}","received_events_url":"https://api.github.com/users/abadger/received_events","type":"User","site_admin":false}],"milestone":null,"comments":11,"created_at":"2016-10-08T16:47:59Z","updated_at":"2016-10-19T09:23:16Z","closed_at":"2016-10-19T09:23:16Z","body":"\r\n##### ISSUE TYPE\r\n - Feature Idea\r\n\r\n##### COMPONENT NAME\r\nVarious templates\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\r\n```\r\ndevel, 2.3, 2.2\r\n```\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly -->\r\nUsing the default values of \"{{ ansible_managed }}\" in a template file leads to the file being changed.  This is due to the variables used in the default definition of ansible_managed:\r\n\r\n* The date replacement leads to it being changed whenever the date of the template's source is different.\r\n  * This can happen when playbooks are stored in git as git does not store file timestamps.  Each checkout creates files from that date.  In a multi-admin setup, it is common for the playbooks to be shared with other admins via git.\r\n* The uid replacement leads to it being changed anytime the playbook is run from a different account.\r\n  * Running ansible does not require a single admin account because of its integration with sudo and su.  But this portion of the string hampers that because template will report changed each time a different account is used.\r\n* The host replacement leads it to being changed whenever the playbook is run from a different controller.\r\n  * Ansible is useful to run playbooks from each admin's laptop or workstation rather than having a single central master.  This setting makes it so templates cannot be used idempotently in that manner.\r\n* The file replacement leads to the file being changed whenever the file is substituted from a different path.\r\n  * When ansible gets its playbooks from a git checkout in each admin's home directory the paths to the template file will be different.  Thus each admin will get a change in the file.\r\n\r\n##### STEPS TO REPRODUCE\r\nRun the following playbook twice to show the first problem with date.  Note that in the real-world, the change in timestamp would come from using a fresh git checkout or a user on another machine, not from state='touch' in the playbook:\r\n\r\n```\r\n---\r\n- hosts: localhost\r\n  gather_facts: False\r\n  tasks:\r\n  - file:\r\n      path: \"/var/tmp/not-idempotent.j2\"\r\n      state: \"touch\"\r\n  - copy:\r\n      content: \"{{'{{ ansible_managed }}\\nSome content\\n'}}\"\r\n      dest: \"/var/tmp/not-idempotent.j2\"\r\n  - template:\r\n      src: \"/var/tmp/not-idempotent.j2\"\r\n      dest: \"/var/tmp/not-idempotent\"\r\n```\r\n\r\nYou can take out the ```file:``` task and run the playbook as another user or on a different control host to see the problems with uid and host respectively.\r\n\r\n##### EXPECTED RESULTS\r\nThe second run of the playbook should show no changes for the template task.\r\n\r\n##### ACTUAL RESULTS\r\nThe template task shows changes every single run:\r\n```\r\nTASK [template] ****************************************************************\r\nchanged: [localhost]\r\n```"}}
{"actor":{"display_login":"dharmabumstead"}}