Create directories based on inventory_hostname with with_items

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:

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!

bad mustache handling

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