Calling a template in a loop will result in the template being called multiple times, and replacing the file on top of itself each time.
You don't want to do that unless the filename changes in each iteration of the loop. On Wed, Sep 3, 2014 at 2:42 PM, anatoly techtonik <[email protected]> wrote: > On Wed, Sep 3, 2014 at 9:34 PM, Dylan Martin <[email protected]> wrote: > > Maybe use a vars file with hash keyed to whatever your situation > requires? > > EG vars file: > > > > --- > > template_var: > > site1: > > name: site1 > > domain: example.com > > site2: > > name: site2 > > domain: anotherexample.com > > > > and in template: > > > > <VirtualHost *:80> > > DocumentRoot /var/www/{{ template_vars[item][name] }} > > ServerName {{ template_vars[item][name] }}{{ > > template_vars[item][domain]}} > > </VirtualHost> > > Using {{ item[..] }} arrays in template arrays is ugly. Template usage > should not depend on if it is called in a loop or as a single run. > > -- > 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/CAPkN8xKqamJh%2Bd8DXoicqLgfJUrE2cE-zYQ_WhQh_qwH%3Dv3%3Dcg%40mail.gmail.com > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CA%2BnsWgzSL%2BijursxuY3OhZ5m_Mp9BbXEt_GhV5aZWpfYqTNHPA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
