I have a scenario where I need to be able to specify to use the group_vars 
for a NTP timeserver, unless the host_vars are defined.  All of the 
variables are going to be coming out of an intermediary document that the 
customer is going to be filling out, like this:

vars/customer_vars.yml
timeserver1_default: 1.1.1.1
timeserver2_default: 1.1.1.2
timeserver1_server1: 1.1.1.3
timeserver2_server1: 1.1.1.4
timeserver2_server2: ~
timeserver2_server2: ~

The above referenced variable file will be called in the playbook itself 
using the vars_files module.  And I know that host_vars take precedence 
over group_vars, so i would like to be able to do this:

group_vars/all.yml

timeserver1: "{{ timeserver1_default }}"
timeserver2: "{{ timeserver2_default }}"


host_vars/server1.yml

timeserver1: "{{ timeserver1_server1 }}"
timeserver2: "{{ timeserver2_server2 }}"



host_vars/server2.yml

timeserver1: "{{ timeserver1_server2 }}"
timeserver2: "{{ timeserver2_server2 }}"


But I need to find a way around the fact, that if the host_var is defined 
in any way, even if its empty, that's the one that gets used.  Does anyone 
know a way to default to a group_var if a host_var is empty? I could rename 
the group_var ones and then write 2 different version of the conf file, 
pulling one if the host_var is empty for a particular server and another if 
its not, but I would really not have to have multiple versions of the same 
form.  It would seem like there is a better way of doing this that I just 
don't know, but maybe not.......

Thanks!

-- 
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/badac335-f3b0-4284-9ca2-19f4136f2748%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to