On Tue, 18 Dec 2018 08:28:18 -0800 (PST) Eric Brewer <[email protected]> wrote:
> 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: ~ Perhaps you have already thought about it, but any reason why you wouldn't make this into a list of NTP servers instead? E.g. timeservers: - 1.1.1.1 - 1.1.1.2 This lets you easily override values per-group and per-host basis, and also makes it pretty clear on what's going on. > 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....... This is going to be one of "those" answers, but the way you are describing it looks to be a bit overcomplicated to me. E.g. even if it can be done, sounds like it would be rather fiddly and unintuitive when you decide to make configuration changes. Best regards -- Branko Majic XMPP: [email protected] Please use only Free formats when sending attachments to me. Бранко Мајић XMPP: [email protected] Молим вас да додатке шаљете искључиво у слободним форматима. -- 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/20181218192818.6d3e87d0%40majic.rs. For more options, visit https://groups.google.com/d/optout.
