# Include directory

**URL:** <https://forum.ansible.com/t/include-directory/18518>\
**Category:** Ansible Developer\
**Created:** [June 16, 2015, 3:21pm UTC](https://forum.ansible.com/t/include-directory/18518 "2015-06-16T15:21:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adham\_H](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Adham\_H](https://forum.ansible.com/u/Adham_H)\
**Post date:** [June 16, 2015, 3:21pm UTC](https://forum.ansible.com/t/include-directory/18518/1 "2015-06-16T15:21:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 16, 2015, 3:22pm UTC](https://forum.ansible.com/t/include-directory/18518/2 "2015-06-16T15:22:48Z")

</div>

isn't this just like include\_vars/with\_items?

---

<div class="post-metadata">

**Author:** ![Hagai\_Kariti](https://avatars.discourse-cdn.com/v4/letter/h/4491bb/32.png) [@Hagai\_Kariti](https://forum.ansible.com/u/Hagai_Kariti)\
**Post date:** [June 16, 2015, 3:42pm UTC](https://forum.ansible.com/t/include-directory/18518/3 "2015-06-16T15:42:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 16, 2015, 3:49pm UTC](https://forum.ansible.com/t/include-directory/18518/4 "2015-06-16T15:49:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Adham\_H](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Adham\_H](https://forum.ansible.com/u/Adham_H)\
**Post date:** [June 16, 2015, 3:50pm UTC](https://forum.ansible.com/t/include-directory/18518/5 "2015-06-16T15:50:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Adham\_H](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Adham\_H](https://forum.ansible.com/u/Adham_H)\
**Post date:** [June 16, 2015, 3:53pm UTC](https://forum.ansible.com/t/include-directory/18518/6 "2015-06-16T15:53:15Z")

</div>

i used the base code in include\_var anyway. it makes senses to have one module.

---

<div class="post-metadata">

**Author:** ![Adham\_H](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Adham\_H](https://forum.ansible.com/u/Adham_H)\
**Post date:** [August 3, 2015, 11:57am UTC](https://forum.ansible.com/t/include-directory/18518/7 "2015-08-03T11:57:21Z")

</div>

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