title: Ansible include_vars into dictionary
body: <p>In my ansible playbook, I read a list of directories into a list. I then want to read a "config.yml" file from each of these directories and put their content into dictionary, so that I can reference the config-data via the directory name from that dictionary.
  The first part is no problem, but I cannot get the second part to work:</p>
  
  <p>Step 1, load directories:</p>
  
  <pre><code>- name: Include directories
    include_vars:
    file: /main-config.yml
    name: config
  </code></pre>
  
  <p>Step 2, load configs from directories:</p>
  
  <pre><code>- name: load deploymentset configurations
    include_vars:
      file: /path/{{ item }}/config.yml
      name: "allconfs.{{ item }}"   ## &lt;&lt; This is the problematic part 
    with_items:
      - "{{ config.dirs }}"
  </code></pre>
  
  <p>I tried different things like <code>"allconfs['{{ item }}']</code>, but none seemed to work. The playbook completed successfully, but the data was not in the dictionary.
  I also tried defining the outer dictionary beforehand, but that did not work either.</p>
  
  <p>The config files themselves are very simple:</p>
  
  <p>/main-config.yml:</p>
  
  <pre><code>dirs:
  - dir1
  - dir2
  - dir3
  </code></pre>
  
  <p>/path/dir1/config.yml:</p>
  
  <pre><code>some_var: "some_val"
  another_var: "another val"
  </code></pre>
  
  <p>I want to be able to then access the values of the config.yml files like this:</p>
  
  <p><code>{{ allconfs.dir1.some_var }}</code></p>
  
  <p><strong><em>UPDATE</em></strong> to try Konstantins approach:</p>
  
  <pre><code>  - name: load deploymentset configurations
      include_vars:
        file: /repo/deploymentsets/{{ item }}/config.yml
        name: "default_config"
      with_items:
      - "{{ config.deploymentsets }}"
      register: default_configs
  
  
    - name: combine configs
      set_fact:
        default_configs: "{{ dict(default_configs.results | json_query('[].[item, ansible_facts.default_config]')) }}"
  </code></pre>
  
  <p>Error message:</p>
  
  <p><code>fatal: [127.0.0.1]: FAILED! =&gt; {"failed": true, "msg": "Unexpected templating type error occurred on ({{ dict(default_configs.results | json_query('[].[item, ansible_facts.default_config]')) }}): &lt;lambda&gt;() takes exactly 0 arguments (1 given)"}</code></p>