{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/39508","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/39508/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/39508/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/39508/events","html_url":"https://github.com/ansible/ansible/issues/39508","id":318943018,"number":39508,"title":"Add `role_name` and `role_path` for use with `ansible_managed` in `ansible.cfg`","user":{"login":"Rylon","id":438452,"avatar_url":"https://avatars1.githubusercontent.com/u/438452?v=4","gravatar_id":"","url":"https://api.github.com/users/Rylon","html_url":"https://github.com/Rylon","followers_url":"https://api.github.com/users/Rylon/followers","following_url":"https://api.github.com/users/Rylon/following{/other_user}","gists_url":"https://api.github.com/users/Rylon/gists{/gist_id}","starred_url":"https://api.github.com/users/Rylon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rylon/subscriptions","organizations_url":"https://api.github.com/users/Rylon/orgs","repos_url":"https://api.github.com/users/Rylon/repos","events_url":"https://api.github.com/users/Rylon/events{/privacy}","received_events_url":"https://api.github.com/users/Rylon/received_events","type":"User","site_admin":false},"labels":[{"id":686214011,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.5","name":"affects_2.5","color":"ededed","default":false},{"id":852590921,"url":"https://api.github.com/repos/ansible/ansible/labels/feature","name":"feature","color":"006b75","default":false},{"id":636352796,"url":"https://api.github.com/repos/ansible/ansible/labels/support:core","name":"support:core","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-30T16:00:27Z","updated_at":"2018-04-30T17:42:02Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"<!---\r\nVerify first that your issue/request is not already reported on GitHub.\r\nTHIS FORM WILL BE READ BY A MACHINE, COMPLETE ALL SECTIONS AS DESCRIBED.\r\nAlso test if the latest release, and devel branch are affected too.\r\nALWAYS add information AFTER (OUTSIDE) these html comments.\r\nOtherwise it may end up being automatically closed by our bot. -->\r\n\r\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest -->\r\n -~ Bug  Report~\r\n- Feature Idea\r\n\r\n##### COMPONENT NAME\r\n<!--- Insert, BELOW THIS COMMENT, the name of the module, plugin, task or feature.\r\nDo not include extra details here, e.g. \"vyos_command\" not \"the network module vyos_command\" or the full path-->\r\nexamples/ansible.cfg\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste, BELOW THIS COMMENT, verbatim output from \"ansible --version\" between quotes below -->\r\n```\r\nansible 2.5.2\r\n```\r\n\r\n##### CONFIGURATION\r\n<!--- If using Ansible 2.4 or above, paste, BELOW THIS COMMENT, the results of \"ansible-config dump --only-changed\"\r\nOtherwise, mention any settings you have changed/added/removed in ansible.cfg\r\n(or using the ANSIBLE_* environment variables).-->\r\nDEFAULT_MANAGED_STR(/path/to/ansible.cfg) = This file is managed by Ansible in the {role_name} role\r\n\r\n##### OS / ENVIRONMENT\r\n<!--- Mention, BELOW THIS COMMENT, 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\nAlso mention the specific version of what you are trying to control,\r\ne.g. if this is a network bug the version of firmware on the network device.-->\r\nN/A\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly -->\r\nI am attempting to use the variables `role_name` and `role_path` inside the `ansible_managed` configuration option\r\n\r\n##### STEPS TO REPRODUCE\r\n<!--- For bugs, show exactly how to reproduce the problem, using a minimal test-case.\r\nFor new features, show how the feature would be used. -->\r\n1. Create a role which uses a J2 template and add a header line `# {{ ansible_managed }}`\r\n2. Create a playbook which includes that role.\r\n3. Create an `ansible.cfg` and set a custom `ansible_managed` using `role_name` or `role_path`, for example `ansible_managed = This file is managed by the {role_name} role`\r\n4. Execute the playbook.\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\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\nI expected the `role_name` variable to be interpolated correctly and a header line added to the resulting templated file of `This file is managed by the my_role role`\r\n\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->\r\nA `KeyError` for `role_name` causes the playbook to fail.\r\n\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\nfatal: [ubuntu-bionic]: FAILED! => {\r\n    \"changed\": false, \r\n    \"msg\": \"KeyError: u'role_name'\"\r\n}\r\n```\r\n\r\nThe interpolation works if I try a different variable, such as `file`. Furthermore using this debug task shows that `role_name` is set to the correct value:\r\n\r\n```yaml\r\n- debug:\r\n    var: role_name\r\n```\r\n\r\n```\r\nok: [ubuntu-bionic] => {\r\n    \"role_name\": \"my_role\"\r\n}\r\n```\r\n\r\nIs it possible to use `role_name` in this fashion?"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/385473705","html_url":"https://github.com/ansible/ansible/issues/39508#issuecomment-385473705","issue_url":"https://api.github.com/repos/ansible/ansible/issues/39508","id":385473705,"user":{"login":"bcoca","id":836171,"avatar_url":"https://avatars1.githubusercontent.com/u/836171?v=4","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"created_at":"2018-04-30T17:42:02Z","updated_at":"2018-04-30T17:42:02Z","author_association":"MEMBER","body":"Changed to feature request, the `ansible_managed` docs clearly states the available variables for use with the macro, any other variables are not supposed to be available."}}
{"actor":{"display_login":"bcoca"}}