Hi,
Can a list have a combination of dict and lists? Below is my data and jinja2 template, while running the play book get an error.
snmp:
location: xyz
contact: admin
- community:
name: public
access: read-only
clients: - hosts: 8.8.8.8
- hosts: 10.10.10.10
- community:
name: private
access: read-write
clients: - hosts: 3.3.3.3
- hosts: 4.4.4.4
snmp {
location “{{ snmp.location }}”“;
contact “{{ snmp.contact }}”;”
{% for snmp in snmp %}
community {{ snmp.community.name }} {
authorization {{ snmp.community.access }};
clients {
{% for client in snmp.community.clients %}
{{ client.hosts }};
{% endfor %}
}
}
{% endfor %}
}
(ansible)Vishals-MBP:ansible vishalc$ ansible-playbook main.yml
ERROR: Syntax Error while loading YAML script, /etc/ansible/group_vars/lab.yml
Note: The error may actually appear before this position: line 27, column 5
contact: admin
- community:
^
Vishal