On 28.04.16 01:04 Eric Marquez wrote: > --- > > VLAN: > > ID: 12 >
I am not sure if it would be better to use lists rather than dicts (if
your syntax is a dict, no expert).
You have two entries called VLAN.
I would use something like this:
vlan_list:
- id12
- id: 12
- name: "Test1"
- shutdown: false
- id13
> .j2 template
>
> {{#
>
> ########################################
>
> Purpose:
>
> Create a Switch Virtual Interface (SVI)
>
>
>
> Required Variables and Types
>
> VLAN.ID (int)
Is this valid syntax? Including this whole block in double curly braces?
> feature interface-vlan
>
>
>
> Vlan{{ VLAN.ID }}
>
> name {{ VLAN.NAME }}
>
> state active
>
> {% if VLAN.SHUTDOWN %}
>
> shutdown
>
> {% else %}
>
> no shutdown
>
> {% endif %}
>
>
>
> interface Vlan{{ VLAN.ID }}
>
> Description {{ VLAN.INTERFACE.DESC }}
>
> {% if VLAN.INTERFACE.SHUTDOWN %}
>
> shutdown
>
> {% else %}
>
> no shutdown
>
> {% endif %}
>
> ip address {{ VLAN.INTERFACE.IPV4.ADDRESS }}
>
>
> I seem to be missing how to setup my template file so I can take
> advantage of this format. I would like to have the for loop
> understand that I have multiple vlan's groups and pass in the
> reference for that instance it's on.
Untested, but when using a list called vlan_list you could loop
through it with something like this
{% for foobar in vlan_list %}
Vlan{{foobar.id}}
{% endfor %}
Johannes
--
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/572831E3.6030404%40ojkastl.de.
For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: OpenPGP digital signature
