You can easily put variables in your template that the template can key off of.
Usage of things like "set_fact" or parameterized role arguments may be relevant here. On Wed, Feb 26, 2014 at 10:08 AM, Andy Altepeter <[email protected]> wrote: > 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 > > > > > > -- > 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/2c4ac5a8-fca2-4b79-9890-5257ff18125d%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- 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/CAEVJ8QP%3DtqDyFfP9qBU-YmTmUy%3DuP2CmvMZUrnLLqQ1yRMvJyA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
