title: How to traverse a nested dict structure with Ansible?
body: <p>I have the following dict structure variable in an ansible playbook:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I need to create a symlink for each of the <code>server_name</code> and <code>server_aliases</code> domains, e.g.:</p>
  
  <pre><code>/tmp/foo.com     -&gt;   /var/www/foo
  /tmp/a.foo.com   -&gt;   /var/www/foo
  /tmp/b.foo.com   -&gt;   /var/www/foo
  /tmp/c.foo.com   -&gt;   /var/www/foo
  /tmp/bar.com     -&gt;   /var/www/bar
  /tmp/d.bar.com   -&gt;   /var/www/bar
  /tmp/e.bar.com   -&gt;   /var/www/bar
  /tmp/f.bar.com   -&gt;   /var/www/bar
  </code></pre>
  
  <p>I have the following task which works for the <code>server_name</code>:</p>
  
  <pre><code>- 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
  </code></pre>
  
  <p>But I'm not sure how I can do the same for the array of <code>server_aliases</code>.</p>
  
  <p>I'm happy to use two separate tasks if necessary, but I'm keen to avoid having to add a separate <code>domains</code> variable which duplicates the list of domains in a flat structure.</p>
  
  <p>This <a href="https://groups.google.com/d/msg/ansible-project/QLqMTV7JKiA/lkoGC_dI2hMJ" rel="noreferrer">Google Groups post</a> is close, but I can't work out how to make it work for multiple virtual hosts. </p>
  
  <p>Is this possible? Or is this fundamentally the wrong approach?</p>