On Tuesday, 18 December 2018 19:45:19 CET Eric Brewer wrote:
> Yeah, that would make it easier, but my constraint is at  the time of 
> writing the code, I won't be able to tell which variable needs to be 
> applied.  Most often, all of the servers are going to use the same IP's for 
> their NTP servers, but I have to leave an option in for one or more servers 
> to use a specific NTP server IP.

You can do that more easily but checking it a specific variable do exist if not 
use the default one
{{ hostvars[inventory_hostname]['timeserver1_' ~ inventory_hostname] | 
default(timeserver1_default) }}


> My variable file was a simplified version 
> of the form that we need to hand out.  What will be handed out is a yml 
> file with variable names and comments in place to explain the purpose of 
> each variable, and instructions on what to fill out and when.

With the above solution is should be easy to explain.


> So I need to 
> system to be flexible enough that it can use the same IP's for NTP for 
> every server, except for where it is specified to be different based on 
> what was and was not filled out on this form.

It's a lot easier to deal with variables not set in Ansible, than the content 
of them.
So if you have the option to leave them out of the configuration instead of 
making them empty.

And in your case it's a lot cleaner and easier to use include_vars instead of 
populate host_vars.


-- 
Kai Stian Olstad


-- 
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/1885675.iV9uQhB039%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to