Create directories based on inventory_hostname with with_items

44 views
Skip to first unread message

Tunghsiao Liu

unread,
Jul 14, 2015, 7:03:25 AM7/14/15
to ansible...@googlegroups.com
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
   
- website2.com
   
- website3.com
  server2
:
   
- website4.com
   
- 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!

Brian Coca

unread,
Jul 14, 2015, 7:20:46 AM7/14/15
to ansible...@googlegroups.com
bad mustache handling

with_items: "{{enabled_sites[inventory_hostname]}}"



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages