Snippet to render jinja files
ansible-playbook render-j2.yml -e @ansible-extra-vars-new.json -e "in=ks8-deploy-nginx.j2 out=nginx.yml"
(ansible-venv) bash-4.4# cat render-j2.yml
---
- hosts: localhost
connection: local
tasks:
- name: Render config for host
template:
src: "{{ in }}"
dest: "{{ out }}"
(ansible-venv) bash-4.4#
Render multiple files in loop, as args hardcoded in playbook
tasks:
- name: Render config for host
template:
src: "{{ item.in }}"
dest: "{{ item.out }}"
loop:
- { in: myfile1.j2, out: myfile1.yml }
- { in: myfile2.j2, out: myfile2.yml }
- { in: myfileN.j2, out: myfileN.yml }
No comments:
Post a Comment