I have the following dict structure variable in an unoccupied play:
apache_vhosts: - name: foo server_name: foo.com server_aliases: - a.foo.com - b.foo.com - c.foo.com - name: bar server_name: bar.com server_aliases: - d.bar.com - e.bar.com - f.bar.com
I need to create a symbolic link for each of the server_name and server_aliases , for example:
/tmp/foo.com -> /var/www/foo /tmp/a.foo.com -> /var/www/foo /tmp/b.foo.com -> /var/www/foo /tmp/c.foo.com -> /var/www/foo /tmp/bar.com -> /var/www/bar /tmp/d.bar.com -> /var/www/bar /tmp/e.bar.com -> /var/www/bar /tmp/f.bar.com -> /var/www/bar
I have the following task that works for server_name :
- name: Add a domain symlinks /tmp for server_name. file: src: "/var/www/{{ item.name }}" dest: "/tmp/{{ item.server_name }}" state: link with_items: apache_vhosts
But I'm not sure how I can do the same for the server_aliases array.
I am happy to use two separate tasks, if necessary, but I try not to add a separate domains variable, which duplicates the list of domains in a flat structure.
This Google Groups post is close, but I canβt decide how to make it work for multiple virtual hosts.
Is it possible? Or is this a fundamentally wrong approach?
source share