02. Templates
ND#6991 C03 L03(Formerly L4) A02 Templates V3
Ansible Templates
Ansible Templates
- Ansible templates enable you to apply configuration files which are customized to fit the application
- Variables are abstracted using the format:
{{ VARIABLE_NAME }}
Templates Example Code
Templates Example Code
File: repo.conf.j2
server {
listen 80;
server_name {{ SERVER_NAME }};
root {{ REPO_PATH }};
location / {
index index.php index.html index.htm;
autoindex on; #enable listing of directory index
}
}
Apply Template
Apply Template
- name: generate all configmap configs
template:
src: repo.conf.j2
dest: /etc/nginx/conf.d/repo.conf
owner: root
group: root
mode: 0744