Ansible: Global template folder?

柔情痞子 提交于 2019-12-23 12:17:04

问题


Couldn't find anything google'ing.

There is group_vars/all/ for variables. Is there something similar for templates? I would like to use some templates across multiple roles.


回答1:


You can put your global templates into templates directory at the top level of Ansible layout (same level as group_vars). BTW same goes for global files.

files/
group_vars/
roles/
site.yml
templates/



回答2:


It was possible before 2.2.1, but not after. See issue 20442.

There's a patch that allows you to do out-of-scope includes.

Also as @René suggests you can try to put your common templates into some role and declare it as dependency or call include_role. As far as I remember while digging the issue, Ansible adds all roles used in current context into search path.




回答3:


A possible solution is to put the reusable template in a dependent role. See role dependencies.



来源:https://stackoverflow.com/questions/46396732/ansible-global-template-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!