{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/10990","labels_url":"https://api.github.com/repos/ansible/ansible/issues/10990/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/10990/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/10990/events","html_url":"https://github.com/ansible/ansible/issues/10990","id":75593827,"number":10990,"title":"Conditional imports does'nt work","user":{"login":"maethor","id":2410576,"avatar_url":"https://avatars.githubusercontent.com/u/2410576?v=3","gravatar_id":"","url":"https://api.github.com/users/maethor","html_url":"https://github.com/maethor","followers_url":"https://api.github.com/users/maethor/followers","following_url":"https://api.github.com/users/maethor/following{/other_user}","gists_url":"https://api.github.com/users/maethor/gists{/gist_id}","starred_url":"https://api.github.com/users/maethor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maethor/subscriptions","organizations_url":"https://api.github.com/users/maethor/orgs","repos_url":"https://api.github.com/users/maethor/repos","events_url":"https://api.github.com/users/maethor/events{/privacy}","received_events_url":"https://api.github.com/users/maethor/received_events","type":"User","site_admin":false},"labels":[{"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/needs_info","name":"needs_info","color":"eb6420"},{"url":"https://api.github.com/repos/ansible/ansible/labels/P3","name":"P3","color":"fef2c0"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-12T12:59:49Z","updated_at":"2015-07-13T19:20:02Z","closed_at":"2015-07-13T19:00:49Z","body":"##### Issue Type:\r\n\r\nBug Report\r\n\r\n##### Ansible Version:\r\n\r\nansible 1.9.1\r\n\r\n##### Ansible Configuration:\r\n\r\n```\r\n[defaults]\r\n\r\nsudo_user=root\r\nask_sudo_pass=true\r\nforks=50\r\npipelining=True\r\nfact_caching=redis\r\nfact_caching_timeout=86400\r\n```\r\n\r\n##### Environment:\r\n\r\nI'm using Debian Stretch on my laptop, Debian 7/8 and CentOS 7 on my servers.\r\n\r\n##### Summary:\r\n\r\nConditional imports (http://docs.ansible.com/playbooks_conditionals.html#conditional-imports) doesn't work as expected.\r\n\r\n##### Steps To Reproduce:\r\n\r\nI have this playbook:\r\n\r\n```\r\n---\r\n- hosts: all:!services\r\n  vars_files:\r\n    - [ \"vars/{{ ansible_os_family }}.yml\", vars/default_os.yml ]\r\n  tasks:\r\n    - debug: var=sudo_group\r\n```\r\n\r\nvars/RedHat.yml contains:\r\n\r\n```\r\n---\r\nsudo_group: wheel\r\n```\r\n\r\nvars/default_os.yml contains:\r\n\r\n```\r\n---\r\nsudo_group: sudo\r\n```\r\n\r\n##### Expected Results:\r\n\r\nThis is what I get when I only put `- [ \"vars/{{ ansible_os_family }}.yml\"]` in `vars_files`\r\n\r\n```\r\nPLAY [all:!services] ********************************************************** \r\n\r\nGATHERING FACTS *************************************************************** \r\nok: [test-centos01.sysnove.net]\r\ntest-centos01.sysnove.net: importing vars/RedHat.yml\r\n\r\nTASK: [debug var=sudo_group] ************************************************** \r\nok: [test-centos01.sysnove.net] => {\r\n    \"var\": {\r\n        \"sudo_group\": \"wheel\"\r\n    }\r\n}\r\n\r\nPLAY RECAP ******************************************************************** \r\ntest-centos01.sysnove.net  : ok=2    changed=0    unreachable=0    failed=0 \r\n```\r\n\r\n##### Actual Results:\r\n\r\nThis is what I get with `- [ \"vars/{{ ansible_os_family }}.yml\", vars/default_os.yml]`.\r\n\r\n```\r\nPLAY [all:!services] ********************************************************** \r\n\r\nGATHERING FACTS *************************************************************** \r\nok: [test-centos01.sysnove.net]\r\n\r\nTASK: [debug var=sudo_group] ************************************************** \r\nok: [test-centos01.sysnove.net] => {\r\n    \"var\": {\r\n        \"sudo_group\": \"sudo\"\r\n    }\r\n}\r\n\r\nPLAY RECAP ******************************************************************** \r\ntest-centos01.sysnove.net  : ok=2    changed=0    unreachable=0    failed=0 \r\n```\r\n\r\n\r\n\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/121028232","html_url":"https://github.com/ansible/ansible/issues/10990#issuecomment-121028232","issue_url":"https://api.github.com/repos/ansible/ansible/issues/10990","id":121028232,"user":{"login":"jimi-c","id":26403,"avatar_url":"https://avatars.githubusercontent.com/u/26403?v=3","gravatar_id":"","url":"https://api.github.com/users/jimi-c","html_url":"https://github.com/jimi-c","followers_url":"https://api.github.com/users/jimi-c/followers","following_url":"https://api.github.com/users/jimi-c/following{/other_user}","gists_url":"https://api.github.com/users/jimi-c/gists{/gist_id}","starred_url":"https://api.github.com/users/jimi-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimi-c/subscriptions","organizations_url":"https://api.github.com/users/jimi-c/orgs","repos_url":"https://api.github.com/users/jimi-c/repos","events_url":"https://api.github.com/users/jimi-c/events{/privacy}","received_events_url":"https://api.github.com/users/jimi-c/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T19:20:02Z","updated_at":"2015-07-13T19:20:02Z","body":"@maethor my apologies, I didn't realize this was a feature. I've corrected it in devel as of now, so this should work as expected.\r\n<pre>\r\n# cat test.yml \r\n- hosts: all:!services\r\n  vars_files:\r\n    - [ \"vars/{{ ansible_os_family }}.yml\", vars/default_os.yml ]\r\n  tasks:\r\n    - debug: var=sudo_group\r\n\r\n# ansible-playbook -vv test.yml -i localhost, -c local\r\nUsing /etc/ansible/ansible.cfg as config file\r\n1 plays in test.yml\r\n\r\nPLAY: ***************************************************************************\r\n\r\nTASK [setup] ********************************************************************\r\nok: [localhost]\r\n\r\nTASK [debug var=sudo_group] *****************************************************\r\nok: [localhost] => {\r\n    \"changed\": false, \r\n    \"sudo_group\": \"wheel\"\r\n}\r\n\r\nPLAY RECAP **********************************************************************\r\nlocalhost                  : ok=2    changed=0    unreachable=0    failed=0   \r\n\r\n</pre>"}}