{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/16953","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/16953/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/16953/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/16953/events","html_url":"https://github.com/ansible/ansible/issues/16953","id":169407745,"number":16953,"title":"Ansible reads group_vars from cwd with precedence","user":{"login":"kustodian","id":1949229,"avatar_url":"https://avatars.githubusercontent.com/u/1949229?v=3","gravatar_id":"","url":"https://api.github.com/users/kustodian","html_url":"https://github.com/kustodian","followers_url":"https://api.github.com/users/kustodian/followers","following_url":"https://api.github.com/users/kustodian/following{/other_user}","gists_url":"https://api.github.com/users/kustodian/gists{/gist_id}","starred_url":"https://api.github.com/users/kustodian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kustodian/subscriptions","organizations_url":"https://api.github.com/users/kustodian/orgs","repos_url":"https://api.github.com/users/kustodian/repos","events_url":"https://api.github.com/users/kustodian/events{/privacy}","received_events_url":"https://api.github.com/users/kustodian/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04"}],"state":"closed","locked":false,"assignee":{"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},"assignees":[{"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},{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","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}],"milestone":null,"comments":2,"created_at":"2016-08-04T15:48:31Z","updated_at":"2016-08-17T21:29:42Z","closed_at":"2016-08-17T21:29:41Z","body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible 2.1.1.0\r\n```\r\n\r\n##### CONFIGURATION\r\nN/A\r\n\r\n##### OS / ENVIRONMENT\r\nUbuntu/CentOS\r\n\r\n##### SUMMARY\r\nIf the inventory and the playbook are not in the current working directory (cwd), and `group_vars` exists in cwd, Ansible will read variables from `cwd/group_vars` and will even give them precedence. This only happens if the same file exists in both group_vars of cwd and the inventory. The \r\n\r\n##### STEPS TO REPRODUCE\r\nHere is a simple repro. Create a file structure like this:\r\n```\r\n├── group_vars\r\n│   └── g1\r\n├── inventories\r\n│   └── test\r\n│       ├── group_vars\r\n│       │   └── g1\r\n│       └── hosts\r\n└── playbooks\r\n    └── site.yml\r\n```\r\n\r\n```yaml\r\n# group_vars/g1\r\n---\r\nvar1: \"Set in CWD\"\r\n```\r\n```ini\r\n# inventories/test/hosts\r\n[g1]\r\nlocalhost\r\n```\r\n```yaml\r\n# inventories/test/group_vars/g1\r\n---\r\nvar1: \"Set in inventory\"\r\n```\r\n```yaml\r\n# playbooks/site.yml\r\n---\r\n- hosts: localhost\r\n  gather_facts: no\r\n  connection: local\r\n  tasks:\r\n    - debug: var=var1\r\n```\r\nRun `site.yml` with this inventory:\r\n```\r\nansible-playbook -i inventories/test/hosts playbooks/site.yml\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nIt should display `var1: \"Set in inventory\"`.\r\n\r\n##### ACTUAL RESULTS\r\nIt actually displays the value of the variable defined in cwd:\r\n```\r\nTASK [debug] *******************************************************************\r\nok: [localhost] => {\r\n    \"var1\": \"Set in CWD\"\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"jimi-c"}}