Greetings,
I have a need to generate multiple configuration files on a single host from one template. Is this possible in ansible?
Let’s say I have a variable like:
vars:
configs:
- port: 8080
directory: /var/www/host1 - port: 8081
directory: /var/www/host2
I need to generate a configuration file for each tuple in this list. The template needs to have access to each tuple in the list using a single name. In a python program it might look like:
for config in configs:
generate_template(config=config)
And the template then uses the variable name “config” to refer to the current tuple.
Is this possible with just ansible? I know I can use with_items to iterate over the list, but does the template have access to the “current” tuple?
Thanks,
Andy