Handle IP addresses configured on disappeared interfaces (#391)
Some checks failed
Collection Docs / Build Ansible Docs (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled
nox / ansible-test (push) Has been cancelled
Collection Docs / Publish Ansible Docs (push) Has been cancelled

* Handle IP addresses configured on disappeared interfaces

* Handle IP addresses configured on disappeared interfaces

Always set type property, add changelog fragment

* Handle IP addresses configured on disappeared interfaces (wording)

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Claudio Luck <claudio.luck@datact.ch>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Claudio Luck 2025-08-19 22:46:38 +02:00 committed by GitHub
parent fb070e4ac6
commit f6aeae1abd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View file

@ -317,8 +317,10 @@ class Interfaces(FactsBase):
def populate_addresses(self, data, family):
for value in data:
key = value['interface']
if family not in self.facts['interfaces'][key]:
self.facts['interfaces'][key][family] = []
iface = self.facts['interfaces'].setdefault(key, (
{"type": "ansible:unknown"} if key.startswith('*') else
{"type": "ansible:mismatch"}))
iface_addrs = iface.setdefault(family, [])
addr, subnet = value['address'].split('/')
subnet = subnet.strip()
# Try to convert subnet to an integer
@ -328,7 +330,7 @@ class Interfaces(FactsBase):
pass
ip = dict(address=addr.strip(), subnet=subnet)
self.add_ip_address(addr.strip(), family)
self.facts['interfaces'][key][family].append(ip)
iface_addrs.append(ip)
def add_ip_address(self, address, family):
if family == 'ipv4':