Dear all,
I am implementing a task which should configure a network interface according to the macaddress.
For example:
“ansible_eth1”: {
“active”: true,
“device”: “eth1”,
“id”: “8000.0050568d1cf8”,
“interfaces”: [
“peth1”
],
“ipv4”: {
“address”: “129.94.72.12”,
“broadcast”: “129.94.72.63”,
“netmask”: “255.255.255.192”,
“network”: “129.94.72.0”
},
“ipv6”: [
{
“address”: “fe80::250:56ff:fe8d:1cf8”,
“prefix”: “64”,
“scope”: “link”
}
],
“macaddress”: “00:50:56:8d:1c:f8”,
“mtu”: 1500,
“promisc”: false,
“stp”: false,
“type”: “bridge”
},
The tricky part is, the device name (such as eth1) is not reliable, the OS may assign differently after reinstallation. So I can only rely on macaddress, then pass the device name to my shell script for configuration.
I attempted to work around with “when” and “with_items” but got syntax error all the time. Can someone show the correct way to do this?
Cheers,
Derrick