each item is stored in a special 'item' variable when you have a with_
loop, so you just need:
dest=/etc/apache2/sites-available/{{item}}.conf
On Wed, May 27, 2015 at 1:08 AM, Amoyensis <[email protected]> wrote:
> Hi all,
>
> I am new to Ansible and I am trying use the template module to create
> different config files.
>
> Here is what I got:
> ├── group_vars
> │ └── web
> └── web
> ├── tasks
> │ └── main.yml
> └── templates
> └── virtualhost.conf
>
> group_vars/web:
>
> domain:
> - alpha
> - bravo
> - charly
>
> /web/tasks/main.yml:
>
> - name: 7. Add Template Module
> template: src=virtualhost.conf
> dest=/etc/apache2/sites-available/{{domain}}.conf
> with_items: domain
>
> I want, that the task creates a file for each array field in the domain
> list. So, what I expect are three files, named alpha.conf beta.conf and
> charly.conf. But I just got one file, called ['alpha', 'bravo',
> 'charly'].conf
>
> Job message:
>
> src=virtualhost.conf dest=/etc/apache2/sites-available/['alpha', 'bravo',
> 'charly'].conf
>
> When I use
>
> with_items:
>
> - alpha
>
> - bravo
>
> - charly
>
> in the task itself, it works. But I want to declare the array in a separate
> file (groupvar).
>
> Can you tell my how to fix this?
>
>
> Kind regards,
>
> Amoyensis
>
> --
> 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/ffb18b94-2281-45f8-b44f-1e2e402a448f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
Brian Coca
--
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/CAJ5XC8n6eSYetY6bUkFN92EuRpvVZ__10dbYfuywm0r4s54OyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.