linux networking facts: Provide IPv4 prefix (#77193)
For IPv6 addresses, Ansible already provides the prefix length for IP addresses in the `prefix` fact. This patch adjusts the facts for IPv4 addresses to also contain the prefix length in the prefix fact. This makes it easier to use the facts consistently when the CIDR notation is needed. Signed-off-by: Till Maas <opensource@till.name>
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
---
|
||||
minor_changes:
|
||||
- facts - report prefix length for IPv4 addresses in Linux network facts.
|
||||
@ -192,7 +192,9 @@ class LinuxNetwork(Network):
|
||||
interfaces[iface]['ipv4'] = {'address': address,
|
||||
'broadcast': broadcast,
|
||||
'netmask': netmask,
|
||||
'network': network}
|
||||
'network': network,
|
||||
'prefix': netmask_length,
|
||||
}
|
||||
else:
|
||||
if "ipv4_secondaries" not in interfaces[iface]:
|
||||
interfaces[iface]["ipv4_secondaries"] = []
|
||||
@ -201,6 +203,7 @@ class LinuxNetwork(Network):
|
||||
'broadcast': broadcast,
|
||||
'netmask': netmask,
|
||||
'network': network,
|
||||
'prefix': netmask_length,
|
||||
})
|
||||
|
||||
# add this secondary IP to the main device
|
||||
@ -213,6 +216,7 @@ class LinuxNetwork(Network):
|
||||
'broadcast': broadcast,
|
||||
'netmask': netmask,
|
||||
'network': network,
|
||||
'prefix': netmask_length,
|
||||
})
|
||||
|
||||
# NOTE: default_ipv4 is ref to outside scope
|
||||
@ -221,6 +225,7 @@ class LinuxNetwork(Network):
|
||||
default_ipv4['broadcast'] = broadcast
|
||||
default_ipv4['netmask'] = netmask
|
||||
default_ipv4['network'] = network
|
||||
default_ipv4['prefix'] = netmask_length
|
||||
# NOTE: macaddress is ref from outside scope
|
||||
default_ipv4['macaddress'] = macaddress
|
||||
default_ipv4['mtu'] = interfaces[device]['mtu']
|
||||
|
||||
Reference in New Issue
Block a user