Hello, This implies that all Jinja2 templates variables should have `item.` prefix, which is ugly, because limits their usage to loop-only tasks.
On Fri, Sep 5, 2014 at 11:38 AM, David Karban <[email protected]> wrote: > Hi, > > not sure I understand your problem correctly, but isn`t this enough? > > - template: dest=/etc/apache2/sites-available/{{ item.domain }} > src=templates/virtualhost.j2 > with_items: > - sitename > > > I presume, sitename is list of names and attributes like: > sitename: > - name: first_domain > domain: www.fomain.tld > - name: second_domain > domain: foo.bar > > in template: > > <VirtualHost *:80> > DocumentRoot /var/www/{{ item.name }} > ServerName {{ item.name }}/{{ item.domain }} > </VirtualHost> > > ? > > > 2014-09-05 8:20 GMT+02:00 anatoly techtonik <[email protected]>: >> >> On Fri, Sep 5, 2014 at 4:20 AM, Michael DeHaan <[email protected]> >> wrote: >> > 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. >> >> I want exactly that - change filename and variables for that filename in >> each >> iteration of the loop. How to do this? >> >> -- >> 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/CAPkN8x%2BB0LwFKjSBV4gOgkSeVgyrrj_gr67Sk7zK6zUWVmyWWg%40mail.gmail.com. >> For more options, visit https://groups.google.com/d/optout. > > > > > -- > David Karban > Specialista na správu linuxových serverů > www.karban.eu > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ansible-project/SulFWHwt_OI/unsubscribe. > To unsubscribe from this group and all its topics, 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/CAOBFM95PSpWtMrphCEbcJFhuUwaf4yeKkbQr8eNFFwY%2B-ipDVg%40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. -- anatoly t. -- 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/CAPkN8xJa-GnGv9nwVyvNZuZpSXZBm3HzcL8UZMN9k1nS5bTGXw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
