In this older question about "Can extra_vars
receive multiple files?", the original poster answered the question, saying that multiple vars files could be accomplished by just using multiple --extra-vars
parameters.
The followup question that I have is that, in such a case, where the ansible-playbook
command line has two --extra-vars
parameters, each pointing to a different file, what is the order or precedence of those files?
Also, what happens if both files have the same var name (e.g., my_host
) in them?
For example, say I have 2 files, extraVars1.yml
and extraVars2.yml
and in the ansible-playbook
command line I have:
ansible-playbook... --extra-vars "@extraVars1.yml" --extra-vars "@extraVars2.yml"
and the extraVars1.yml
file has:
my_host: 1.2.3.4
and the extraVars2.yml
file has:
my_host: 5.6.7.8
What will the value of the my_host
var be when the playbook is run?
Thanks! Jim