prole/infrastructure/roles/netplan_static/tests/render_template.yml

30 lines
975 B
YAML

---
- name: Render netplan_static template and verify YAML is valid
hosts: localhost
connection: local
gather_facts: false
become: false
vars:
# Representative values (mirrors `inventory/host_vars/merlin.prole.org.yml`)
netplan_static_iface_effective: eth0
netplan_static_address: 10.0.0.6/24
netplan_static_gateway4_effective: 10.0.0.1
netplan_static_nameservers_effective:
- 10.0.0.1
_rendered_path: /tmp/netplan_static_rendered.yaml
tasks:
- name: Render template
ansible.builtin.template:
src: "{{ playbook_dir }}/../templates/99-ansible-static.yaml.j2"
dest: "{{ _rendered_path }}"
mode: "0600"
- name: Parse rendered YAML with the same Python used by ansible-playbook
ansible.builtin.command: >-
{{ ansible_playbook_python }} -c
"import yaml; yaml.safe_load(open('{{ _rendered_path }}', 'r', encoding='utf-8').read()); print('YAML ok')"
changed_when: false