Some Ansible roles, such as https://github.com/bertvv/ansible-role-hosts, use template files that may be a near miss for the needs of this project. When the role author has not provided a variable substitution for the name of the template, is there still a way to replace the template file? Obviously, I could fork the role and use my own fork, but I'm hoping there's a better answer, such as "just drop your replacement template file in the templates directory of your role that depends on Bert's role."
Asked
Active
Viewed 3,172 times
2 Answers
4
Playbook pathing has some "do what I mean" magic for relative paths. rolename/templates is searched first in dependency order, then {{playbook_dir}}/templates
You cannot change this without altering the role somehow, one of:
altering the src file name
adding a dependency on your role that provides a different template of the same name
editing their template
I like changing the file name the best. Send them a change that make the source template name into a variable in role defaults.
John Mahowald
- 36,071
1
If you are willing to have changes occur at every ansible run you could use a lineinfile task on the instantiated template file (i.e. the dest in the template task) after the role is applied.
Mark Wagner
- 18,428