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