That works, thanks!

On Sunday, July 5, 2015 at 5:10:18 PM UTC+5:30, Jan Grant wrote:
>
> Not quite, but you can have a dictionary member whose value is a list: 
>
> snmp: 
>       location: xyz 
>       contact: admin 
>       community: 
>         - name: public 
>           access: read-only 
>           clients: 
>             - hosts: 8.8.8.8 
>             - hosts: 10.10.10.10 
>         - name: private 
>           access: read-write 
>           clients: 
>             - hosts: 3.3.3.3 
>             - hosts: 4.4.4.4 
>
> And here, each element of the 'community' list is a dict. 
>
>
> On Sun, 5 Jul 2015, Vishal Chainani wrote: 
>
> > 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 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <javascript:>. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/17d716b2-0180-45a1-8c49-f61e6ef88ecd%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
> > 
>
> -- 
> [email protected] <javascript:>  http://ioctl.org/jan/ Short, dark, ugly: 
> pick any three 
> The only certain way to prevent another 9/11 is via universal calendar 
> reform. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/17eb2088-7df8-456f-bff1-ed841ac9a9f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to