{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/18154","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/18154/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/18154/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/18154/events","html_url":"https://github.com/ansible/ansible/issues/18154","id":184697365,"number":18154,"title":"inventory/playbook group_vars/<group> has high precedence than inventory file vars ，inventory file vars has high precedence than inventory/playbook group_vars/all","user":{"login":"GoodHaHa","id":7147143,"avatar_url":"https://avatars1.githubusercontent.com/u/7147143?v=4","gravatar_id":"","url":"https://api.github.com/users/GoodHaHa","html_url":"https://github.com/GoodHaHa","followers_url":"https://api.github.com/users/GoodHaHa/followers","following_url":"https://api.github.com/users/GoodHaHa/following{/other_user}","gists_url":"https://api.github.com/users/GoodHaHa/gists{/gist_id}","starred_url":"https://api.github.com/users/GoodHaHa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoodHaHa/subscriptions","organizations_url":"https://api.github.com/users/GoodHaHa/orgs","repos_url":"https://api.github.com/users/GoodHaHa/repos","events_url":"https://api.github.com/users/GoodHaHa/events{/privacy}","received_events_url":"https://api.github.com/users/GoodHaHa/received_events","type":"User","site_admin":false},"labels":[{"id":437720699,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.2","name":"affects_2.2","color":"5319e7","default":false},{"id":849212023,"url":"https://api.github.com/repos/ansible/ansible/labels/docs","name":"docs","color":"0052cc","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2016-10-23T15:45:04Z","updated_at":"2018-05-29T13:12:22Z","closed_at":"2017-04-10T17:41:47Z","author_association":"NONE","body":"<!---\nPlease do not report issues/requests related to Ansible modules here !!\n\nReport them to the appropriate modules-core or modules-extras project:\n  - https://github.com/ansible/ansible-modules-core/issues\n  - https://github.com/ansible/ansible-modules-extras/issues\n\nAlso verify first that your issue/request is not already reported in GitHub\n-->\n##### ISSUE TYPE\n\n<!--- Pick one below and delete the rest: -->\n- Documentation Report\n##### COMPONENT NAME\n\n<!--- Name of the plugin/task/feature -->\n\nN/A\n##### ANSIBLE VERSION\n\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\n\n```\nansible 2.2.0.0\n  config file = /etc/ansible/ansible.cfg\n  configured module search path = Default w/o override\n```\n##### CONFIGURATION\n\n<!---\nMention any settings you have changed/added/removed in ansible.cfg\n(or using the ANSIBLE_* environment variables).\n-->\n##### OS / ENVIRONMENT\n\n<!---\nMention the OS you are running Ansible from, and the OS you are\nmanaging, or say “N/A” for anything that is not platform-specific.\n-->\n##### SUMMARY\n\n<!--- Explain the problem briefly -->\n\ninventory/playbook group_vars/<group> has high precedence than inventory file vars ，inventory file vars has high precedence than inventory/playbook group_vars/all\n##### STEPS TO REPRODUCE\n\n<!---\nFor bugs, show exactly how to reproduce the problem.\nFor new features, show how the feature would be used.\n-->\n\n<!--- Paste example playbooks or commands between quotes below -->\n\nIs document wrong? The results showed that the actual order of precedence(from low to high):\n- playbook group_vars/all\n- inventory group_vars/all \n- inventory file vars\n- inventory group_vars/test\n- playbook group_vars/test\n### structure\n\n```\n├── hosts\n│   └── inventory_test\n│   └── group_vars\n│      ├── all\n│      └── ansible_test\n└── playbook_var.yaml\n```\n### invertory:\n\n```\n# cat hosts/inventory_test \n[ansible_test:children]\ngroup1\ngroup2\n\n[group1]\n10.15.222.207\n\n[group2]\n10.15.222.208\n10.15.222.209\n\n[ansible_test:vars]\nvars_test=\"in inventory\"\n\n[group1:vars]\nvars_test=\"in group1\"\n```\n### inventory group_vars/all :\n\n```\n\ncat hosts/group_vars/all \n\n---\n\nvars_test: \"in group_vars/all\"\n```\n### inventory group_vars/ansible_test\n\n```\n# cat hosts/group_vars/ansible_test \n\n---\n\nvars_test: \"in group_all/ansible_test\"\n```\n### If I use group_vars/ansible_test and group_vars/all, I can get:\n\n```\n# ansible-playbook --limit=ansible_test -i hosts/inventory_test playbook_var.yml \n\nPLAY [ansible_test] ************************************************************\n\nTASK [setup] *******************************************************************\nok: [10.15.222.208]\nok: [10.15.222.207]\nok: [10.15.222.209]\n\nTASK [debug] *******************************************************************\nok: [10.15.222.207] => {\n    \"msg\": \"in group_all/ansible_test\"\n}\nok: [10.15.222.208] => {\n    \"msg\": \"in group_all/ansible_test\"\n}\nok: [10.15.222.209] => {\n    \"msg\": \"in group_all/ansible_test\"\n}\n\nPLAY RECAP *********************************************************************\n10.15.222.207              : ok=2    changed=0    unreachable=0    failed=0   \n10.15.222.208              : ok=2    changed=0    unreachable=0    failed=0   \n10.15.222.209              : ok=2    changed=0    unreachable=0    failed=0   \n\n```\n### And then If I do not use group_vars/ansible_test but use group_vars/all, I can get:\n\n```\n# ansible-playbook --limit=ansible_test -i hosts/inventory_test playbook_var.yml \n\nPLAY [ansible_test] ************************************************************\n\nTASK [setup] *******************************************************************\nok: [10.15.222.209]\nok: [10.15.222.207]\nok: [10.15.222.208]\n\nTASK [debug] *******************************************************************\nok: [10.15.222.208] => {\n    \"msg\": \"in inventory\"\n}\nok: [10.15.222.207] => {\n    \"msg\": \"in group1\"\n}\nok: [10.15.222.209] => {\n    \"msg\": \"in inventory\"\n}\n\nPLAY RECAP *********************************************************************\n10.15.222.207              : ok=2    changed=0    unreachable=0    failed=0   \n10.15.222.208              : ok=2    changed=0    unreachable=0    failed=0   \n10.15.222.209              : ok=2    changed=0    unreachable=0    failed=0 \n```\n\nSo I find the vars in the inventory group_vars/all  file will be overridden by in the inventory\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/392770479","html_url":"https://github.com/ansible/ansible/issues/18154#issuecomment-392770479","issue_url":"https://api.github.com/repos/ansible/ansible/issues/18154","id":392770479,"user":{"login":"joshbenner","id":79151,"avatar_url":"https://avatars3.githubusercontent.com/u/79151?v=4","gravatar_id":"","url":"https://api.github.com/users/joshbenner","html_url":"https://github.com/joshbenner","followers_url":"https://api.github.com/users/joshbenner/followers","following_url":"https://api.github.com/users/joshbenner/following{/other_user}","gists_url":"https://api.github.com/users/joshbenner/gists{/gist_id}","starred_url":"https://api.github.com/users/joshbenner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshbenner/subscriptions","organizations_url":"https://api.github.com/users/joshbenner/orgs","repos_url":"https://api.github.com/users/joshbenner/repos","events_url":"https://api.github.com/users/joshbenner/events{/privacy}","received_events_url":"https://api.github.com/users/joshbenner/received_events","type":"User","site_admin":false},"created_at":"2018-05-29T13:12:22Z","updated_at":"2018-05-29T13:12:22Z","author_association":"NONE","body":"@andrew-sumner: This works for me:\r\n\r\n```ini\r\nprecedence = all_plugins_play, all_inventory, all_plugins_inventory, groups_plugins_play, groups_inventory, groups_plugins_inventory\r\n```\r\n\r\nWith this setup, inventory-based group_vars override playbook-based group_vars."}}
{"actor":{"display_login":"joshbenner"}}