title: ansible postgres add multiple extensions to database (nested loop)
body: <p>For creating PostgreSQL databases I use the following schema:</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  postgres_database:
    - name: test
      user: test
      pass: secret
  
    - name: test2
      user: test2
      pass: secret
  
  </code></pre>
  <p>But now I need to add <a href="https://www.postgresql.org/download/products/6-postgresql-extensions/" rel="nofollow noreferrer">extensions</a> per database so I thought of using something like:</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  postgres_database:
    - name: test
      user: test
      pass: secret
      extensions:
        - unaccent
        - pgcrypto
        - uuid-ossp
  
    - name: test2
      user: test2
      pass: secret
  
    - name: test3
      user: test3
      pass: secret
      extensions:
        - pgcrypto
       
  </code></pre>
  <p>The problem I have is that I can only pass an extension at a time, therefore wondering how could I loop over the items<code>postgres_database.extensions</code> within the <code>posgres_database</code> loop?</p>
  <p>Currently, this works but only adds the first extension found:</p>
  <pre class="lang-yaml prettyprint-override"><code>- name: add extensions
    become: yes
    become_user: postgres
    postgresql_ext:
      name: &quot;{{ item.extensions[0] }}&quot;
      db: &quot;{{ item.name }}&quot;
    when: item.extensions is defined
    with_items:
      - &quot;{{ postgres_database }}&quot;
  </code></pre>
  <p>Any ideas about how could this be solved?</p>