{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/15548","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/15548/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/15548/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/15548/events","html_url":"https://github.com/ansible/ansible/issues/15548","id":150384304,"number":15548,"title":"The include_vars module variables can't be overridden with task level variable definitions.","user":{"login":"chriskarel","id":11828048,"avatar_url":"https://avatars.githubusercontent.com/u/11828048?v=3","gravatar_id":"","url":"https://api.github.com/users/chriskarel","html_url":"https://github.com/chriskarel","followers_url":"https://api.github.com/users/chriskarel/followers","following_url":"https://api.github.com/users/chriskarel/following{/other_user}","gists_url":"https://api.github.com/users/chriskarel/gists{/gist_id}","starred_url":"https://api.github.com/users/chriskarel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriskarel/subscriptions","organizations_url":"https://api.github.com/users/chriskarel/orgs","repos_url":"https://api.github.com/users/chriskarel/repos","events_url":"https://api.github.com/users/chriskarel/events{/privacy}","received_events_url":"https://api.github.com/users/chriskarel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-22T14:29:52Z","updated_at":"2016-04-22T14:29:52Z","closed_at":null,"body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n\r\n##### ANSIBLE VERSION\r\n```\r\n# ansible-playbook --version\r\nansible-playbook 2.0.1.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### CONFIGURATION\r\nDefault install via EPEL repos.\r\n\r\n\r\n##### OS / ENVIRONMENT\r\n\r\nOracle Enterprise Linux 7 (RHEL7 equivalent)\r\n\r\n\r\n##### SUMMARY\r\ninclude_vars module results in variables that cannot be overridden by task level definitions.  Or at least have too high a precedence.\r\n\r\n##### STEPS TO REPRODUCE\r\nImport variables with include_vars, then override it with a task specific variable that should have a higher priority.\r\n\r\n```\r\n# cat test.yaml\r\n---\r\n- name: Test variable precedence\r\n  hosts: localhost\r\n  tasks:\r\n     - name: Should be \"foo\"\r\n       debug: msg=\"Variable is _{{dummyvar}}_\"\r\n       vars:\r\n         dummyvar: 'foo'\r\n     - include_vars: vars.yaml\r\n     - name: Should be \"bar\"\r\n       debug: msg=\"Variable is _{{dummyvar}}_\"\r\n       vars:\r\n         dummyvar: 'bar'\r\n```\r\n\r\n```\r\n# cat vars.yaml\r\ndummyvar: WRONG\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nI would have expected the variable to be set to 'foo' and 'bar' respectively\r\neg:\r\n````\r\n# ansible-playbook test.yaml \r\nPLAY [Test variable precedence] ************************************************\r\n\r\nTASK [setup] *******************************************************************\r\nok: [localhost]\r\n\r\nTASK [Should be \"foo\"] *********************************************************\r\nok: [localhost] => {\r\n    \"msg\": \"Variable is _foo_\"\r\n}\r\n\r\nTASK [include_vars] ************************************************************\r\nok: [localhost]\r\n\r\nTASK [Should be \"bar\"] *********************************************************\r\nok: [localhost] => {\r\n    \"msg\": \"Variable is _bar_\"\r\n}\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=4    changed=0    unreachable=0    failed=0   \r\n````\r\n\r\n##### ACTUAL RESULTS\r\nInstead, the 'bar' variable setting is overridden by the previous include_vars, resulting in the value being \"wrong\".  This seems contrary to the [documented precedence order](http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable).\r\n\r\n```\r\n # ansible-playbook test.yaml \r\nPLAY [Test variable precedence] ************************************************\r\n\r\nTASK [setup] *******************************************************************\r\nok: [localhost]\r\n\r\nTASK [Should be \"foo\"] *********************************************************\r\nok: [localhost] => {\r\n    \"msg\": \"Variable is _foo_\"\r\n}\r\n\r\nTASK [include_vars] ************************************************************\r\nok: [localhost]\r\n\r\nTASK [Should be \"bar\"] *********************************************************\r\nok: [localhost] => {\r\n    \"msg\": \"Variable is _WRONG_\"\r\n}\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=4    changed=0    unreachable=0    failed=0   \r\n```\r\n\r\n##### Related issue\r\nI see someone opened [a similar issue for v1.9](https://github.com/ansible/ansible/issues/15483), but seemed to believe it was fixed in 2.x.  This is definitely still occurring in v2.x."}}