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