Perhaps it’s an easy question but I cannot find a way to answer it myself.
More in details – I have two groups in my inventory: clients (many hosts) and server (single host), and a template at the client which needs to use the server address. If it happens that a client host is also in the ‘server’ group, I wanted to set the address in the template to ‘localhost’. Otherwise, the address should point to the server address as specified in the inventory. I guess it’s quite easy to code it using jinja2 directly in the template but my template includes many places with such a reference, so I thought about first setting the server address variable, and then using this variable to evaluate the template. Is this correct way of thinking? How can I set a variable in a play before template evaluation? Otherwise, have you got any other ideas?
That’s nice. One thing I’m not sure about is the ‘server_address_here’ which you wrote. Ideally, what I need there is the name/address of the first (and the only) host in the inventory group ‘server’.
Is there a way to do this?
Cheers,
Jacek
W dniu czwartek, 18 września 2014 01:41:55 UTC+1 użytkownik James Cammarata napisał: