{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/31593","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/31593/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/31593/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/31593/events","html_url":"https://github.com/ansible/ansible/issues/31593","id":264670099,"number":31593,"title":"Dynamically excluded tasks are still evaluated","user":{"login":"foben","id":2573068,"avatar_url":"https://avatars0.githubusercontent.com/u/2573068?v=4","gravatar_id":"","url":"https://api.github.com/users/foben","html_url":"https://github.com/foben","followers_url":"https://api.github.com/users/foben/followers","following_url":"https://api.github.com/users/foben/following{/other_user}","gists_url":"https://api.github.com/users/foben/gists{/gist_id}","starred_url":"https://api.github.com/users/foben/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foben/subscriptions","organizations_url":"https://api.github.com/users/foben/orgs","repos_url":"https://api.github.com/users/foben/repos","events_url":"https://api.github.com/users/foben/events{/privacy}","received_events_url":"https://api.github.com/users/foben/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-10-11T17:24:49Z","updated_at":"2017-10-11T17:24:49Z","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 - Bug Report\r\n\r\n##### COMPONENT NAME\r\ninclude_tasks\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible-playbook 2.5.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = [u'/home/felix/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/lib/python2.7/site-packages/ansible-2.5.0-py2.7.egg/ansible\r\n  executable location = /usr/bin/ansible-playbook\r\n  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]\r\n```\r\n\r\n##### CONFIGURATION\r\n```\r\nANSIBLE_NOCOWS(env: ANSIBLE_NOCOWS) = True\r\nPERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 30\r\n```\r\n\r\n##### OS / ENVIRONMENT\r\nFedora 24, running local playbook\r\n\r\n##### SUMMARY\r\nThe include_tasks feature does not behave as expected. Particularly the 'dynamic' aspect that is emphasized in the documentation does not work.\r\nExecuting the playbook.yml posted below:\r\n```\r\nansible-playbook playbook.yml\r\n```\r\nIt seems to me that the pre 2.4 behavior is still present - the condition is simply applied to every single included task, instead of dynamically skipping the include due to the failing conditional.\r\nThe documentation [here](http://docs.ansible.com/ansible/latest/playbooks_reuse.html) suggests a different behavior.\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*playbook.yml*:\r\n```yaml\r\n---\r\n- hosts: 127.0.0.1\r\n  gather_facts: no\r\n\r\n  tasks:\r\n  \r\n  - name: \"Include Task\"\r\n    import_tasks: include.yml\r\n    when: False\r\n```\r\n*include.yml*:\r\n```yaml\r\n- name: \"Include 1\"\r\n  debug:\r\n    msg: \"Include 1\"\r\n\r\n- name: \"Include 2\"\r\n  debug:\r\n    msg: \"Include 2\"\r\n\r\n- name: \"Include 3\"\r\n  debug:\r\n    msg: \"Include 3\"\r\n```\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\nExpected something along those lines:\r\n\r\n```\r\n\r\nPLAY [127.0.0.1] *********************************************************************************************************************************************\r\n\r\nTASK [Include Task] *********************************************************************************************************************************************\r\nskipping: [127.0.0.1]\r\n\r\nPLAY RECAP ***************************************************************************************************************************************************\r\n127.0.0.1                  : ok=0    changed=0    unreachable=0    failed=0   \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<!--- Paste verbatim command output between quotes below -->\r\n```\r\n\r\nPLAY [127.0.0.1] *********************************************************************************************************************************************\r\n\r\nTASK [Include 1] *********************************************************************************************************************************************\r\nskipping: [127.0.0.1]\r\n\r\nTASK [Include 2] *********************************************************************************************************************************************\r\nskipping: [127.0.0.1]\r\n\r\nTASK [Include 3] *********************************************************************************************************************************************\r\nskipping: [127.0.0.1]\r\n\r\nPLAY RECAP ***************************************************************************************************************************************************\r\n127.0.0.1                  : ok=0    changed=0    unreachable=0    failed=0   \r\n\r\n```\r\n"}}
{"actor":{"display_login":"foben"}}