OK, so what I mean is: if you set an inventory variable in the hosts file and in host_vars, which takes precedence, and can I depend on this?
The reason: I want to distribute some re-usable configs (these are virtual lab setups) to multiple users. I want to put the “normal” configs somewhere, and also have a single place where the user can override them. e.g.
host_vars/s1
lan_address: 10.10.0.241
So everyone who builds the lab will have normally have s1’s lan address as 10.10.0.241. But if they want to, they can edit the hosts file as an override:
“if you set an inventory variable in the hosts file and in host_vars, which takes precedence, and can I depend on this?”
No, you can’t.
Best practices would suggest putting variables only in host_vars/group_vars, unless it’s something like an ansible_ control variable, where having that in inventory can be convient.
I ran across this same “not issue” thinking that my host_vars/x.yml would override the inventory file. I get the Ansible Zen approach, and now that I know the answer from MD above, I am A-OK. I think it would be nice if this information was covered in the Ansible docs specifically so folks can easy access to this answer.
I had similar doubts last week, got my answers on the irc channel.
Quick question for Michael, do you use git for your documentation pages or is it wiki based? I would be happy to submit a pull request with enhancements to the docs.
It would also help me with my bad memory