Include directory

Hi,

I created a small action module that include files under a directory as an array. Take this as an example

Directory structure

  • users/
  • user1.yml
  • user2.yml
  • user3.yml

Ansible code

  • name: Set fact for user site
    include_dir:
    path=“/path_to_my_dir/users”
    fact=“system_users”

So I searched a lot and did not find a solution, I might be missing something and an easier solution might exist. If not I would like to see this functionality in core.

isn't this just like include_vars/with_items?

Well, it does create a new fact containing all the objects in the files. There’s so way to do that currently, because you can’t expand list abd dicts.

sounds like something we should add to include_vars vs creating a
competing plugin, if possible.

a better name would probably include dir as list. So you can then use to loop over a list.

We use that to load chef databags and niginx conf and other stuff.

i used the base code in include_var anyway. it makes senses to have one module.

Should I open issue. a pull request details Mo June 2015 at 5:53:17 PM UTC+2, Adham H wrote: