title: In Ansible, how to combine variables from separate files into one array?
body: <p>In Ansible, in a role, I have vars files like this:</p>
  
  <pre><code>vars/
      app1.yml
      app2.yml
  </code></pre>
  
  <p>Each file contains vars specific to an app/website like this:</p>
  
  <pre><code>name: app1
  git_repo: https://github.com/philgyford/app1.git
  # ...
  </code></pre>
  
  <p>Ideally, without the task knowing in advance which apps have variable files, I'd like to end up with an array called <code>apps</code> like this:</p>
  
  <pre><code>apps:
    - name: app1
      git_repo: https://github.com/philgyford/app1.git
      # ...
    - name: app2
      git_repo: https://github.com/philgyford/app2.git
      # ...
  </code></pre>
  
  <p>ie, that combines the variables from the files into one.</p>
  
  <p>I know I can load all the variable files like this:</p>
  
  <pre><code>- name: Load var files
    with_fileglob:
      - ../vars/*.yml
    include_vars: '{{ item }}'
  </code></pre>
  
  <p>But given each file has identical variable names, it will overwrite each previous set of variables. I can't see a way to load the variables and put them into an <code>apps</code> array.</p>
  
  <p>I'm open to rearranging things slightly if it's the only way to make something like this possible.</p>