Ansible: Global template folder?
Asked Answered
W

3

10

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.

Willamina answered 25/9, 2017 at 2:19 Comment(0)
S
17

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/
Selfabuse answered 6/10, 2017 at 16:21 Comment(0)
N
6

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.

Neologism answered 25/9, 2017 at 6:38 Comment(0)
D
1

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

Dickens answered 25/9, 2017 at 4:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.