9

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.

kev
  • 8,928
  • 14
  • 61
  • 103

3 Answers3

16

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/
and
  • 2,024
  • 3
  • 24
  • 31
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.

Konstantin Suvorov
  • 65,183
  • 9
  • 162
  • 193
1

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

René Pijl
  • 4,310
  • 1
  • 19
  • 25