title: Ansible how to create list of dictionary keys
body: <p>I am probably missing something simple. I have the dictionary in vars.yml</p>
  
  <pre><code>deploy_env:
    dev:
      schemas:
        year1:
          - main
          - custom
        year2:
          - main
          - custom
          - security
        year3:
          - main
          - custom
  </code></pre>
  
  <p>then in my playbook.yml I have something like</p>
  
  <pre><code>- set_fact:
      years: "{{ deploy_env.dev.schemas }}"
  
  - name: Create schemas
    shell: "mysql ....params go here... {{ item }}"
    with_nested:
      - "{{ years }}"
  </code></pre>
  
  <p>The above works fine if schemas in <strong>vars.yml</strong> was a simple list ie:</p>
  
  <pre><code>...schemas:
       - year1
       - year2
       - year3
  </code></pre>
  
  <p>But as soon as I add additional items under each year (making this a dictionary(?) I start getting errors on the line: <strong><em>- "{{ years }}"</em></strong>.</p>
  
  <p>I basically want to populate <strong>{{ years }}</strong> with <em>year1</em>,<em>year2</em>,<em>year3</em> values for this task.</p>
  
  <p>I've looked at many examples but everything I looked at was soo complex and it was about how to create dictionaries which is not helpful.</p>
  
  <p>Thanks!</p>