cobbler_system: fix KeyError when adding new interface to existing system (#11995)

* fix(cobbler_system): handle missing interface device on existing system

When adding a new interface to an existing Cobbler system that does not
yet have that interface defined, the module raised a KeyError. Use .get()
with a fallback empty dict to safely handle that case. Also add a
continue after the unknown-property warning to prevent a secondary
KeyError on IFPROPS_MAPPING lookup.

Fixes: #7007

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore(cobbler_system): add changelog fragment for #11995

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky
2026-05-07 05:29:23 +12:00
committed by GitHub
parent 38d49d240e
commit 02b969ee4d
2 changed files with 6 additions and 1 deletions

View File

@@ -298,7 +298,8 @@ def main():
continue
if key not in IFPROPS_MAPPING:
module.warn(f"Property '{key}' is not a valid system property.")
if not system or system["interfaces"][device][IFPROPS_MAPPING[key]] != value:
continue
if not system or system["interfaces"].get(device, {}).get(IFPROPS_MAPPING[key]) != value:
result["changed"] = True
interface_properties[f"{key}-{device}"] = value