Using with_items inside vars_files in an Ansible playbook
<p>I'm currently making the transition from Puppet to Ansible and so far so good. Yet I want to automatize as much as possible.</p>

<p>I'm trying to use a <code>with_items</code> loop inside <code>vars_files</code> to load variable files based on a given list of items. Ansible complains about the syntax and I can't seem to find an example of a similar solution, only examples that use <code>with_items</code> inside tasks and roles.</p>

<p>For example:</p>

<pre><code>vars_files:
  - ["vars/{{ item }}-{{ ansible_fqdn }}.yml", "vars/{{ item }}-{{ system_environment }}.yml", "vars/{{ item }}.yml"]
    with_items:
      - php
      - nginx
</code></pre>

<p>The goal here is to loop the second line for as long as there are items in <code>with_items</code> using an array to fallback on the next item if it can't find the given file (which works).</p>

<p>Not sure if this is at all possible, but I wanted to ask before taking another direction.</p>