# Is there something like "group\_files"

**URL:** <https://forum.ansible.com/t/is-there-something-like-group-files/24391>\
**Category:** Ansible Project\
**Created:** [May 3, 2017, 5:14pm UTC](https://forum.ansible.com/t/is-there-something-like-group-files/24391 "2017-05-03T17:14:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_Penas](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Carlos\_Penas](https://forum.ansible.com/u/Carlos_Penas)\
**Post date:** [May 3, 2017, 5:14pm UTC](https://forum.ansible.com/t/is-there-something-like-group-files/24391/1 "2017-05-03T17:14:36Z")

</div>

I’m a bit new to ansible and perhaps I slip pass over this feature.

I’ve read the ansible best practices document and choosed a directory layout like this

`ansible ├── roles │ ├── ... │ ├── staging │ ├── inventory │ └── group_vars │ ├── all │ ├── app │ └── web └── production ├── inventory └── group_vars ├── all ├── app └── web`

This is perfect for configuring different secrets and variables for different groups in different stages and reuse the same playbook/roles for any different environment which is a quite elegant solution, the problem comes when I need to use a “copy” or “template” task and the file varies in each stage, for example a server certificate which varies with the host name of the stack configured…

In templates you can always add some logic, but this smells a bit odd to me, because you are tying your role to the architecture. (Correct me if I’m wrong but it looks like insert business logic in a view of a MVC framework). The same for roles’ tasks lists

As far as I know ansible looks for files in each ./files/ directory of the related role

Is there another path dependant of the inventory used were I can store stage dependant files that the roles can refer only by basename?

If there isn’t

Any way to emulate it (maybe adding something like a search path at playbook level) ?

Thanks

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [May 4, 2017, 7:28am UTC](https://forum.ansible.com/t/is-there-something-like-group-files/24391/2 "2017-05-04T07:28:53Z")

</div>

Be wary of looking at Ansible with an MVC perspective; the burden  
of maintaining a few dozen YAML files and templates doesn't need  
the overhead of OOPs baggage, and in my experience the readability  
cost isn't worth it.

That said: perhaps parameterised roles would do what you want?  
Passing in paths to certs. etc when you apply the role in your playbook  
should give you the flexibility you want.

[http://docs.ansible.com/ansible/playbooks\_roles.html#id8](http://docs.ansible.com/ansible/playbooks_roles.html#id8)

---

<div class="post-metadata">

**Author:** ![Carlos\_Penas](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Carlos\_Penas](https://forum.ansible.com/u/Carlos_Penas)\
**Post date:** [May 4, 2017, 2:06pm UTC](https://forum.ansible.com/t/is-there-something-like-group-files/24391/3 "2017-05-04T14:06:35Z")

</div>

> Be wary of looking at Ansible with an MVC perspective; the burden  
> of maintaining a few dozen YAML files and templates doesn’t need  
> the overhead of OOPs baggage, and in my experience the readability  
> cost isn’t worth it.

Is not form, My concert are more for internal role reusability than correctness.

> That said: perhaps parameterised roles would do what you want?  
> Passing in paths to certs. etc when you apply the role in your playbook  
> should give you the flexibility you want.
> 
> [http://docs.ansible.com/ansible/playbooks\_roles.html#id8](http://docs.ansible.com/ansible/playbooks_roles.html#id8)

At last I made it using a “files//” dir and referring as files/{{ stage }}/{{ item }} in my playbooks, since seems that src looks in the “./files” of role’s root then in the role’s root and then in ansible’s dir root for file objects if path is relative

Thanks anyway
