I am using the zzet.rbenv role on my playbook. It has a files/default-gems file that it copies to the provisioned system.
I need my playbook to check for a myplaybook/files/default-gems and use it if it exists, using the zzet.rbenv/files/default-gems if otherwise.
How can I do that?
After some research and trial/error. I found out that Ansible is not capable of checking if files exist between roles. This is due to the way role dependencies (which roles themselves) will get expanded into the one requiring it, making it part of the playbook. There are no tasks that will let you differentiate
my_role/files/my_file.txtfromrequired_role/files/my_file.txt.One approach to the problem (the one I found the easiest and cleanest) was to:
my_rolewith the path to the file I want to use (overriding the default one)Example
required_role
my_role
As mentioned by Ramon de la Fuente: this solution was accepted into the zzet.rbenv repo :)