Is there something like "group_files"

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

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

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

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