# Use Array/list file in with\_items

**URL:** <https://forum.ansible.com/t/use-array-list-file-in-with-items/18315>\
**Category:** Ansible Project\
**Created:** [May 27, 2015, 5:08am UTC](https://forum.ansible.com/t/use-array-list-file-in-with-items/18315 "2015-05-27T05:08:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amoyensis](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Amoyensis](https://forum.ansible.com/u/Amoyensis)\
**Post date:** [May 27, 2015, 5:08am UTC](https://forum.ansible.com/t/use-array-list-file-in-with-items/18315/1 "2015-05-27T05:08:51Z")

</div>

Hi all,

I am new to Ansible and I am trying use the template module to create different config files.

```auto
Here is what I got:
├── group_vars
│ └── web
└── web
    ├── tasks
    │ └── main.yml
    └── templates
        └── virtualhost.conf

```

group\_vars/web:

```auto
domain:
- alpha
- bravo
- charly

```

/web/tasks/main.yml:

```auto
- 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:

```auto
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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 27, 2015, 11:03am UTC](https://forum.ansible.com/t/use-array-list-file-in-with-items/18315/2 "2015-05-27T11:03:19Z")

</div>

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
