Calling "sub" variable in task

Hi,

I'm trying to deploy Apache with virtualhosts and their aliases and directories. In order to do so I've setup vars host_vars, Apache vhost config template and task file. With this setup I can create complete config per virtualhost, but I can't figure out how to call the var within task to create the directory.

host_vars/myhost example with two virtualhosts:

The reason this doesn't work is that your vhost_dir is a list.

Perhaps you could use something like:

    - name: create additional vhost dirs
      file: path={{ item.1 }} state=directory group=apache mode=0755
      when: apache_vhosts is defined
      with_subelements:
        - apache_vhosts
        - vhost_dirs

http://docs.ansible.com/playbooks_loops.html#looping-over-subelements

-- ams