{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/13054","labels_url":"https://api.github.com/repos/ansible/ansible/issues/13054/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/13054/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/13054/events","html_url":"https://github.com/ansible/ansible/issues/13054","id":115403681,"number":13054,"title":"inventory variables should have more weight","user":{"login":"RainerW","id":118649,"avatar_url":"https://avatars.githubusercontent.com/u/118649?v=3","gravatar_id":"","url":"https://api.github.com/users/RainerW","html_url":"https://github.com/RainerW","followers_url":"https://api.github.com/users/RainerW/followers","following_url":"https://api.github.com/users/RainerW/following{/other_user}","gists_url":"https://api.github.com/users/RainerW/gists{/gist_id}","starred_url":"https://api.github.com/users/RainerW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RainerW/subscriptions","organizations_url":"https://api.github.com/users/RainerW/orgs","repos_url":"https://api.github.com/users/RainerW/repos","events_url":"https://api.github.com/users/RainerW/events{/privacy}","received_events_url":"https://api.github.com/users/RainerW/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-05T23:58:08Z","updated_at":"2015-11-09T16:35:58Z","closed_at":"2015-11-09T16:35:58Z","body":"When running a playbook, variables defined in the inventory ( or inventory groups) should have a higher weight then playbook group_vars. They should actually be at the same 'level' als the extra vars ( http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable ).\r\n\r\nWhy?\r\nBecause inventories are a commandline option and naturally they are therefore very specific for a given environment. One would expected them to overwrite playbooks variables.\r\nE.g. we use the same playbook in all our enviroments. And let the designated site-teams provide their inventory with environment specific endpoints, key and certs etc. And these should not be checked in a low(er) security repository ( even with vault ).\r\n\r\nWorkarounds:\r\n\r\n* extra vars\r\nThis works, but does not have the power of groups, so you cannot have one site.yml run, but  differences in group variables.\r\n\r\n* group_vars\r\nWill overwrite the inventory, but not playbook variables ( that only works with extra vars ).\r\n\r\nSuggestion:\r\nSort variable precedence from the less specific ones to more specific ones:\r\n\r\n  * role defaults\r\n  * playbook group_vars\r\n  * playbook host_vars\r\n  * host facts\r\n  * registered vars\r\n  * set_facts\r\n  * play vars\r\n  * play vars_prompt\r\n  * play vars_files\r\n  * role and include vars\r\n  * block vars (only for tasks in block)\r\n  * task vars (only for the task)\r\n  * > inventory vars <\r\n  * > inventory group_vars <\r\n  * > inventory host_vars <\r\n  * extra vars\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/155116582","html_url":"https://github.com/ansible/ansible/issues/13054#issuecomment-155116582","issue_url":"https://api.github.com/repos/ansible/ansible/issues/13054","id":155116582,"user":{"login":"abadger","id":209242,"avatar_url":"https://avatars.githubusercontent.com/u/209242?v=3","gravatar_id":"","url":"https://api.github.com/users/abadger","html_url":"https://github.com/abadger","followers_url":"https://api.github.com/users/abadger/followers","following_url":"https://api.github.com/users/abadger/following{/other_user}","gists_url":"https://api.github.com/users/abadger/gists{/gist_id}","starred_url":"https://api.github.com/users/abadger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadger/subscriptions","organizations_url":"https://api.github.com/users/abadger/orgs","repos_url":"https://api.github.com/users/abadger/repos","events_url":"https://api.github.com/users/abadger/events{/privacy}","received_events_url":"https://api.github.com/users/abadger/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T16:35:58Z","updated_at":"2015-11-09T16:35:58Z","body":"This is something to discuss on the mailing list and then open a ticket if the consensus there is that this is a change we want to implement.  Looking at where inventory has sat historically, I think it's likely the consensus will be that it's too big a backwards compatibility break to change.  However your CLI rationale is worth mentioning to see if it persuades anyone.  I'll paste the list information below.\r\n\r\nSubmission Received\r\n===================\r\n\r\nCan you please post on ansible-development list so we can talk about this idea with the wider group?\r\n\r\n   * https://groups.google.com/forum/#!forum/ansible-devel\r\n\r\nThank you once again for this and your interest in Ansible!\r\n"}}