Hello all,

I am a Network Engineer and Ansible is relative new for me.

At the moment I am trying to build a template with "JSON" as source. See 
below.

The template should do the follwing (hopefully you get the idea).
I am struggling, how can i get the items in the list "INT_LIST" ?
Can someone point my to a good sample or documentation.

TIA
Juergen

------------------
Jinja Template
------------------
{% for host in host_with_properties %}

hostname  {{ host.HOST_NAME }}

{% for item in INT_LIST %}

interface {{ item.int_phy01 }}

{% endfor %}
{% endfor %}

------------------------------

Source:
----------
{
"all_hosts_unique":
[
    "host01",
    "host02"
],

"host_with_properties":
[
    {
        "HOST_NAME": "host01",
        "INT_LIST": [
            {
                "beid": "100",
                "dot1qid": "10",
                
            },
            {
                "beid": "100",
                "dot1qid": "11",
                "hsrp_ip": "10.10.20.1",
                "int_be_desc": "test",
                "int_phy01": "TenGigE0/0/0/3",
                "int_phy01_desc": "test02",
                "int_phy02": "TenGigE0/0/0/4",
                "int_phy02_desc": "test03",
                "int_sub_desc": "test",
                "int_sub_ip": "10.10.20.11",
                "int_sub_net": "255.255.255.0",
                "int_sub_vrf": "mgt-net"
            },
            {
                "beid": "100",
                "dot1qid": "12",
                "hsrp_ip": "10.10.30.1",
                "int_be_desc": "test",
                "int_phy01": "TenGigE0/0/0/5",
                "int_phy01_desc": "test03",
                "int_phy02": "TenGigE0/0/0/6",
                "int_phy02_desc": "test04",
                "int_sub_desc": "test",
                "int_sub_ip": "10.10.30.12",
                "int_sub_net": "255.255.255.0",
                "int_sub_vrf": "mgt-net"
            }
        ]
    },
    {
        "HOST_NAME": "host02",
        "INT_LIST": [
            {
                "beid": "111",
                "dot1qid": "10",
                "hsrp_ip": "10.10.10.1",
                "int_be_desc": "test",
                "int_phy01": "TenGigE0/0/0/7",
                "int_phy01_desc": "test01",
                "int_phy02": "TenGigE0/0/0/2",
                "int_phy02_desc": "test02",
                "int_sub_desc": "test",
                "int_sub_ip": "10.10.10.10",
                "int_sub_net": "255.255.255.0",
                "int_sub_vrf": "mgt-net"
            },
            {
                "beid": "222",
                "dot1qid": "11",
                "hsrp_ip": "10.10.20.1",
                "int_be_desc": "test",
                "int_phy01": "TenGigE0/0/0/8",
                "int_phy01_desc": "test02",
                "int_phy02": "TenGigE0/0/0/4",
                "int_phy02_desc": "test03",
                "int_sub_desc": "test",
                "int_sub_ip": "10.10.20.11",
                "int_sub_net": "255.255.255.0",
                "int_sub_vrf": "bla-net"
            },
            {
                "beid": "333",
                "dot1qid": "12",
                "hsrp_ip": "10.10.30.1",
                "int_be_desc": "test",
                "int_phy01": "TenGigE0/0/0/9",
                "int_phy01_desc": "test03",
                "int_phy02": "TenGigE0/0/0/6",
                "int_phy02_desc": "test04",
                "int_sub_desc": "test",
                "int_sub_ip": "10.10.30.12",
                "int_sub_net": "255.255.255.0",
                "int_sub_vrf": "gu-net"
            }
        ]
    }
]
}

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/98d06d13-edb2-44fd-95c4-bf70eeef18fa%40googlegroups.com.

Reply via email to