Hi,

As of 2.0 the precedence is 


   - role defaults [1] 
   <http://docs.ansible.com/ansible/playbooks_variables.html#id8>
   - inventory vars [2] 
   <http://docs.ansible.com/ansible/playbooks_variables.html#id9>
   - inventory group_vars
   - inventory host_vars
   - playbook group_vars
   - playbook host_vars
   - host facts
   - registered vars
   - set_facts
   - play vars
   - play vars_prompt
   - play vars_files
   - role and include vars
   - block vars (only for tasks in block)
   - task vars (only for the task)
   - extra vars

http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable

Prior to 1.5.4 we kept default variables in the playbooks 
group_vars/all.yml and overrode in the group specific group_vars, followed 
by the inventory

We have worked round the 1.5.4 -> pre 2.0 precedence but do struggle with 
default values that don't aren't defined in a role. I appreciate that that 
is the preferred approach but this would mean that we would have to include 
the role default everywhere we use it. 

I have situation whereby I want to override a variable stored in 
group_vars/some_group.yml in an inventory. We have informix_server_host 
which on most of our ec2 environments defaults to localhost. On a handle 
for boxes I need to add the db server host. I would like to set a localhost 
default and override in the specific inventory but this isn't possible. 

If I remove the value from group_vars/ I need to set localhost in every 
inventory or set localhost in the role default and include that defaults 
file in every place this is used. 

I would have thought that inventory vars would be one of the most specific 
behind extra vars and task vars. It feels like we are doing something 
wrong, but we are forced into duplicating variables everywhere at the 
moment.

Sorry for waffling but i'd be keen to hear if anybody has a good approach 
to handling defaults that are common to many inventories but need to be 
overriden on an inventory basis.

Many thanks

James


-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0c74b3bd-cb07-4323-9edd-bbd232beab0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to