Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible: Global template folder?

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.

like image 889
kev Avatar asked Sep 25 '17 02:09

kev


People also ask

Where are Ansible templates stored?

Templates usually are stored under “templates” directories with “. j2” file extension. The “dest” parameter specifies the path where to render the template on the remote machine. The “validate” parameters allow you to specify the validation command to run before copying it into place.

What is the default directory structure for Ansible?

Sample directory layout By default, Ansible assumes your playbooks are stored in one directory with roles stored in a sub-directory called roles/ . As you use Ansible to automate more tasks, you may want to move your playbooks into a sub-directory called playbooks/ .

How do I find my role path in Ansible?

Role Search Path By default, in /etc/ansible/roles.

How do I use Ansible template module?

We need to have two parameters when using the Ansible Template module, such as: src: The source of the template file. It can be a relative and absolute path. dest: Dest is the destination path on the remote server.


1 Answers

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/
like image 149
and Avatar answered Oct 05 '22 11:10

and