# Create directories based on inventory\_hostname with with\_items

**URL:** <https://forum.ansible.com/t/create-directories-based-on-inventory-hostname-with-with-items/18752>\
**Category:** Ansible Project\
**Created:** [July 14, 2015, 6:06am UTC](https://forum.ansible.com/t/create-directories-based-on-inventory-hostname-with-with-items/18752 "2015-07-14T06:06:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tunghsiao\_Liu](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Tunghsiao\_Liu](https://forum.ansible.com/u/Tunghsiao_Liu)\
**Post date:** [July 14, 2015, 6:06am UTC](https://forum.ansible.com/t/create-directories-based-on-inventory-hostname-with-with-items/18752/1 "2015-07-14T06:06:02Z")

</div>

Hello,

I’m trying to creating directories based on different inventory\_hostname with with\_items but it seems doesn’t work:

in hosts:

`[website-static-pages] server1 server2`

in vars.yml:

`  
enabled\_sites:  
server1:

- [website1.com](http://website1.com)
- [website2.com](http://website2.com)
- [website3.com](http://website3.com)  
server2:
- [website4.com](http://website4.com)
- [website5.com](http://website5.com)  
`

in task.yml:

`

- name: create site public directories  
file: path=/srv/www/{{ item }}/public\_html/ state=directory  
with\_items: enabled\_sites[“{{ inventory\_hostname }}”]  
`

It seems that this syntax doesn’t work with Ansible, any idea?

Thank you!

---

<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:** [July 14, 2015, 11:20am UTC](https://forum.ansible.com/t/create-directories-based-on-inventory-hostname-with-with-items/18752/2 "2015-07-14T11:20:43Z")

</div>

bad mustache handling

with\_items: "{{enabled\_sites[inventory\_hostname]}}"
