Vlan interfaces

Hi,

Usually vlan interfaces have a ‘.’ in their names. So it isn’t possible to get information (like address) from jinja form because ‘.’ is used to access attributes.
Instead of having vlan interface like a physical in facts, I suggest to have something like this:

“ansible_eth2”: {
“active”: true,
“device”: “eth2”,
“macaddress”: “00:11:22:33:44:55”,
“module”: “ixgbe”,
“mtu”: 1500,
“promisc”: false,
“type”: “ether”,
“vlans”: {
“2111”: {
“device”: “eth2.2111”,
“ipv4”: {
“address”: “10.118.5.241”,
“netmask”: “255.255.255.0”,
“network”: “10.118.5.0”
},
“ipv4_secondaries”:
},
“2112”: {
“device”: “eth2.2112”,
“ipv4”: {
“address”: “10.118.6.241”,
“netmask”: “255.255.255.0”,
“network”: “10.118.6.0”
},
“ipv4_secondaries”:
}
}
}

What do you think about this ?

Did you tried hostvars[‘hostname’][‘ansible_eth2.2111’][‘ipv4’][‘address’]? It works fine for interfaces with ‘.’ in name.

Yes I tried. It works fine when ‘hostname’ is an another host. If ‘hostname’ is the host on which playbook is running it becomes complex.