How to read variable file each iteration of a task?

So, the general idea is I’ve got a playbook that has a set of “property” files (yaml format). Different filenames, but the variable names inside are the same:

`
group_vars/siteA.yml

Have you considered conditional includes? Along with include_vars I think you should be able to achieve the desired effect.

Something like the below:

`

Yes, thanks I think that does help some. I think the part I’m missing still is how to somehow pull in each file name one at a time. I know in pseudo-code it’s something like

`
for( one_filename in fileglob( vars/*.yml) {

  • include_vars “{{ one_filename ))”
  • debug: msg=“{{ site_name }} on port {{ port }}”
    }

`

I know you can’t just do something like

`

  • include_vars “{{ item }}”
    with_fileglob:
  • “vars/*.yml”

`
since that’s going to just pull in the whole list immediately and print out the results at the end.

I just realized I left out one key piece of info on this. It’s all running on localhost always. The idea with this is we’re generating a series of config files locally that a separate script later is going to deal with actually pushing out (for various reasons it needs to be outside of Ansible for now). So unfortunately I don’t think we can take advantage of inventory or group.