diff --git a/docsite/rst/playbooks2.rst b/docsite/rst/playbooks2.rst index ff6f953de7..f3b8f04ede 100644 --- a/docsite/rst/playbooks2.rst +++ b/docsite/rst/playbooks2.rst @@ -656,17 +656,19 @@ You have already learned about inventory host and group variables, 'vars', and ' If a variable name is defined in more than one place with the same name, priority is as follows to determine which place sets the value of the variable. -1. Variables loaded from YAML files mentioned in 'vars_files' in a playbook. +1. Variables specified via command line with --extra-vars. -2. 'vars' as defined in the playbook. +2. Variables loaded from YAML files mentioned in 'vars_files' in a playbook. -3. facts, whether built in or custom, or variables assigned from the 'register' keyword. +3. 'vars' as defined in the playbook. -4. variables passed to parameterized task include statements. +4. facts, whether built in or custom, or variables assigned from the 'register' keyword. -5. Host variables from inventory. +5. variables passed to parameterized task include statements. -6. Group variables from inventory, in order of least specific group to most specific. +6. Host variables from inventory. + +7. Group variables from inventory, in order of least specific group to most specific. Therefore, if you want to set a default value for something you wish to override somewhere else, the best place to set such a default is in a group variable. diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 349618faa1..2f5b2eea73 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -189,9 +189,8 @@ class Play(object): else: raise errors.AnsibleError("'vars_prompt' section is malformed, see docs") - results = self.playbook.extra_vars.copy() - results.update(vars) - return results + vars.update(self.playbook.extra_vars) + return vars # *************************************************