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."
How to replace a template file in an Ansible role
ansibleansible-galaxyansible-playbook
Related Topic
- Ansible Multiple Application Role Approach
- Lazy evaluation of “composed” default variable in dependent Ansible role
- Creating an instance service file using an ansible template
- Ansible replace all values with matching variable name
- How to use list to create users with this Ansible role
- Ansible jinja2 template from JSON format provided as extra-vars
Best Answer
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.