Hi, 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.
Thank you. -- Jeremy On Monday, October 21, 2013 8:16:55 PM UTC-5, Michael DeHaan wrote: > > "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. > > > > > > > On Mon, Oct 21, 2013 at 5:34 AM, candlerb <[email protected] <javascript:> > > wrote: > >> On Sunday, 20 October 2013 02:19:16 UTC+1, Michael DeHaan wrote: >> >>> Specifically what sentence or statement is unclear? I'd be happy to >>> clarify >>> >>> As for "Some experimentation has shown that a variable set in the >>> inventory file appears to take precedence over host_vars." >>> >>> These are equivalent ways to set inventory variables. >>> >>> >> 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: >> >> s1 ansible_connection=local lan_address=1.2.3.4 >> >> Regards, >> >> Brian. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > Michael DeHaan <[email protected] <javascript:>> > CTO, AnsibleWorks, Inc. > http://www.ansibleworks.com/ > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b6051eff-7159-46a3-bbf4-46b2a7ca9414%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
