{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/29541","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/29541/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/29541/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/29541/events","html_url":"https://github.com/ansible/ansible/issues/29541","id":256707349,"number":29541,"title":"including tasks in dependent roles, when running the parent role via include_role","user":{"login":"kraduk","id":13217245,"avatar_url":"https://avatars2.githubusercontent.com/u/13217245?v=4","gravatar_id":"","url":"https://api.github.com/users/kraduk","html_url":"https://github.com/kraduk","followers_url":"https://api.github.com/users/kraduk/followers","following_url":"https://api.github.com/users/kraduk/following{/other_user}","gists_url":"https://api.github.com/users/kraduk/gists{/gist_id}","starred_url":"https://api.github.com/users/kraduk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kraduk/subscriptions","organizations_url":"https://api.github.com/users/kraduk/orgs","repos_url":"https://api.github.com/users/kraduk/repos","events_url":"https://api.github.com/users/kraduk/events{/privacy}","received_events_url":"https://api.github.com/users/kraduk/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":48276055,"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04","default":false},{"id":705713566,"url":"https://api.github.com/repos/ansible/ansible/labels/include_role","name":"include_role","color":"d93f0b","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":6,"created_at":"2017-09-11T13:43:34Z","updated_at":"2018-02-05T11:24:20Z","closed_at":null,"author_association":"NONE","body":"<!---\r\nVerify first that your issue/request is not already reported on GitHub.\r\nAlso test if the latest release, and master branch are affected too.\r\n-->\r\n\r\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Bug Report\r\n\r\n\r\n##### COMPONENT NAME\r\n<!--- Name of the module/plugin/task/feature -->\r\ninclude_role\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\r\n```\r\n# ansible --version\r\n[DEPRECATED] [defaults]hostfile: The key is misleading as it can also be a list of hosts, a directory or a list of paths. It will be removed in 2.8. As alternative use one of [inventory]\r\nansible 2.5.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible\r\n  executable location = /usr/local/bin/ansible\r\n  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]\r\n\r\n```\r\n\r\n##### CONFIGURATION\r\n<!---\r\n[defaults]\r\ninventory = ./inventories/dev\r\nroles_path    = /etc/ansible/roles:./roles\r\nstdout_callback = skippy\r\nhost_key_checking = False\r\nforce_color = 1\r\ncallback_whitelist = profile_tasks\r\nstdout_callback=debug\r\nstderr_callback=debug\r\nallow_world_readable_tmpfiles=True\r\n\r\n[ssh_connection]\r\ncontrol_path = %(directory)s/%%h-%%r\r\npipelining = True\r\n\r\n-->\r\n\r\n##### OS / ENVIRONMENT\r\n<!---\r\nLinux jenkins2 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux\r\n not relevant env vars set\r\n-->\r\n\r\n##### SUMMARY\r\nOk role A includes role B in its tasks. However Role B depends on role C. Role C has an include_tasks in its tasks. This all appears to work. However on close inspection it appears that the include_tasks in role C actually gets the file with a prefix of role Bs role_path. Therefore includes the wrong tasks.\r\n\r\neg\r\n\r\n````\r\nrole A, tasks/main.yml\r\n\r\n- name: setup jobs\r\n    include_role:\r\n      name: ROLEB\r\n\r\nRole B, meta/main.yml\r\n\r\ndependencies:\r\n  - { role: ROLEC, when: full_deploy, var1: \"{{var1}}\", var2: \"{{var2}}\" }\r\n\r\nRole C, tasks/main.yml\r\n\r\n- include_tasks: tasks.yml\r\n\r\n\r\nresult\r\n\r\n13:46:11 TASK [RoleC : include_tasks] ***********************************************\r\n13:46:11 Monday 11 September 2017  13:46:11 +0100 (0:00:00.139)       0:00:30.537 ****** \r\n13:46:11 included: /var/lib/jenkins/jobs/deploy/workspace/roles/roleB/tasks/tasks.yml for www1, www2\r\n13:46:11 \r\n````\r\n\r\n\r\n\r\n##### STEPS TO REPRODUCE\r\n<!---\r\nFor 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\n-->\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```yaml\r\n\r\n```\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\n$ ansible-playbook -i inv deploy.yml  -u ubuntu | sed \"s/.insighthub.io//g\"\r\n[DEPRECATED] [defaults]hostfile: The key is misleading as it can also be a list of hosts, a directory or a list of paths. It will be removed in 2.8. As alternative use one of [inventory]\r\n[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it can also be a list of hosts, a directory or a list of paths . This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting\r\ndeprecation_warnings=False in ansible.cfg.\r\n\r\nPLAY [Deploy ROLEA] **********************************************************************************************************************************************************************************************************************\r\n\r\nTASK [ROLEA : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.035)       0:00:00.035 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEA, file main.yml\r\n\r\n\r\nTASK [ROLEA : include_tasks] *************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.059)       0:00:00.094 ******\r\nincluded: /var/lib/jenkins/ansible-tests/roles/ROLEA/tasks/tasks.yml for www1\r\n\r\nTASK [ROLEA : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.031)       0:00:00.125 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEA, file main.yml\r\n\r\n\r\nTASK [ROLEA : include roleB] *************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.059)       0:00:00.185 ******\r\n\r\nTASK [ROLEC : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.040)       0:00:00.226 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEC, file main.yml\r\n\r\n\r\nTASK [ROLEC : include_tasks] *************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.061)       0:00:00.287 ******\r\nincluded: /var/lib/jenkins/ansible-tests/roles/ROLEC/tasks/tasks.yml for www1\r\n\r\nTASK [ROLEC : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.031)       0:00:00.318 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEC\r\n[include_role_bug.zip](https://github.com/ansible/ansible/files/1292727/include_role_bug.zip)\r\n\r\n, file tasks.yml\r\n\r\n\r\nTASK [ROLEB : include_tasks] *************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.061)       0:00:00.380 ******\r\nincluded: /var/lib/jenkins/ansible-tests/roles/ROLEB/tasks/tasks.yml for www1\r\n\r\nTASK [ROLEB : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.031)       0:00:00.412 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEB, file tasks.yml\r\n\r\n\r\nPLAY RECAP *******************************************************************************************************************************************************************************************************************************\r\nwww1         : ok=8    changed=0    unreachable=0    failed=0\r\n\r\n$\r\n\r\n````\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->\r\n\r\n````\r\n$ ansible-playbook -i inv deploy.yml  -u ubuntu | sed \"s/.insighthub.io//g\"\r\n[DEPRECATED] [defaults]hostfile: The key is misleading as it can also be a list of hosts, a directory or a list of paths. It will be removed in 2.8. As alternative use one of [inventory]\r\n[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it can also be a list of hosts, a directory or a list of paths . This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting\r\ndeprecation_warnings=False in ansible.cfg.\r\n\r\nPLAY [Deploy ROLEA] **********************************************************************************************************************************************************************************************************************\r\n\r\nTASK [ROLEA : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.035)       0:00:00.035 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEA, file main.yml\r\n\r\n\r\nTASK [ROLEA : include_tasks] *************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.059)       0:00:00.094 ******\r\nincluded: /var/lib/jenkins/ansible-tests/roles/ROLEA/tasks/tasks.yml for www1\r\n\r\nTASK [ROLEA : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.031)       0:00:00.125 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEA, file main.yml\r\n\r\n\r\nTASK [ROLEA : include roleB] *************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.059)       0:00:00.185 ******\r\n\r\nTASK [ROLEC : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.040)       0:00:00.226 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEC, file main.yml\r\n\r\n\r\nTASK [ROLEC : include_tasks] *************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.061)       0:00:00.287 ******\r\nincluded: /var/lib/jenkins/ansible-tests/roles/ROLEB/tasks/tasks.yml for www1\r\n\r\nTASK [ROLEC : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.031)       0:00:00.318 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEB, file tasks.yml\r\n\r\n\r\nTASK [ROLEB : include_tasks] *************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.061)       0:00:00.380 ******\r\nincluded: /var/lib/jenkins/ansible-tests/roles/ROLEB/tasks/tasks.yml for www1\r\n\r\nTASK [ROLEB : debug] *********************************************************************************************************************************************************************************************************************\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.031)       0:00:00.412 ******\r\nok: [www1] => {}\r\n\r\nMSG:\r\n\r\nWe are in role: ROLEB, file tasks.yml\r\n\r\n\r\nPLAY RECAP *******************************************************************************************************************************************************************************************************************************\r\nwww1         : ok=8    changed=0    unreachable=0    failed=0\r\n\r\nMonday 11 September 2017  14:36:53 +0100 (0:00:00.060)       0:00:00.472 ******\r\n===============================================================================\r\nROLEC : debug --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.06s\r\nROLEC : debug --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.06s\r\nROLEB : debug --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.06s\r\nROLEA : debug --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.06s\r\nROLEA : debug --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.06s\r\nROLEA : include roleB ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.04s\r\nROLEB : include_tasks ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.03s\r\nROLEC : include_tasks ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.03s\r\nROLEA : include_tasks ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.03s\r\n````\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\nansible-playbook -i inv deploy.yml  -u ubuntu\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/363056933","html_url":"https://github.com/ansible/ansible/issues/29541#issuecomment-363056933","issue_url":"https://api.github.com/repos/ansible/ansible/issues/29541","id":363056933,"user":{"login":"duck-rh","id":19259504,"avatar_url":"https://avatars0.githubusercontent.com/u/19259504?v=4","gravatar_id":"","url":"https://api.github.com/users/duck-rh","html_url":"https://github.com/duck-rh","followers_url":"https://api.github.com/users/duck-rh/followers","following_url":"https://api.github.com/users/duck-rh/following{/other_user}","gists_url":"https://api.github.com/users/duck-rh/gists{/gist_id}","starred_url":"https://api.github.com/users/duck-rh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duck-rh/subscriptions","organizations_url":"https://api.github.com/users/duck-rh/orgs","repos_url":"https://api.github.com/users/duck-rh/repos","events_url":"https://api.github.com/users/duck-rh/events{/privacy}","received_events_url":"https://api.github.com/users/duck-rh/received_events","type":"User","site_admin":false},"created_at":"2018-02-05T11:24:20Z","updated_at":"2018-02-05T11:24:20Z","author_association":"NONE","body":"Quack, works for me with the real-life case."}}
{"actor":{"display_login":"duck-rh"}}