Hi,
I’m wondering if anyone knows of any tricks for neatly handling common file dependencies for roles. I initially thought having a common dependent role in meta/main.yml would facilitate this but apparently dependencies don’t apply to files (which does make sense if roles are though of as totally isolated), but is there some way to achieve this? Or is there some way to specify search paths for files inside a role or something?
So far the best I’ve come up with is putting a files and/or templates directory in the root of the ansible directory and then referencing files/templates with src=file/myfile.txt and/or src=templates/mytemplate.txt (I’ve also seen the recommendation to use src={{ inventory_dir }}/files/myfile.txt but that doesn’t seem necessary). The problem with this is that it doesn’t really organise dependencies for roles but rather just lumps everything into one directory and makes it difficult to share roles externally.
Alternatively, is there some way to specify multiple task files in a role so that all other components can be shared, i.e. something like the following (or Chef cookbook recipes really)
- name: myplay
roles: - myrole.create (roles/myrole/tasks/create.yml)
- myrole (roles/myrole/tasks/main.yml)
- myrole.delete (roles/myrole/tasks/delete.yml)
Regards,
Yoshi