From c42857cdb6e0d627629ebd2928136dcff4842c52 Mon Sep 17 00:00:00 2001 From: Tomas Kloda Date: Fri, 27 Mar 2026 14:30:41 +0100 Subject: [PATCH] fixed comparison issue in other modules --- plugins/modules/netbird_policy.py | 5 +++-- plugins/modules/netbird_posture_check.py | 16 ++++++++++++---- plugins/modules/netbird_route.py | 7 ++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/plugins/modules/netbird_policy.py b/plugins/modules/netbird_policy.py index 7d32f47..94b16ef 100644 --- a/plugins/modules/netbird_policy.py +++ b/plugins/modules/netbird_policy.py @@ -318,8 +318,9 @@ def policy_needs_update(current, params): """Check if policy needs to be updated.""" if params.get('name') is not None and current.get('name') != params['name']: return True - if params.get('description') is not None and current.get('description') != params['description']: - return True + if params.get('description') is not None: + if (current.get('description') or '') != (params['description'] or ''): + return True if params.get('enabled') is not None and current.get('enabled') != params['enabled']: return True if params.get('source_posture_checks') is not None: diff --git a/plugins/modules/netbird_posture_check.py b/plugins/modules/netbird_posture_check.py index 7a25cda..8f4513b 100644 --- a/plugins/modules/netbird_posture_check.py +++ b/plugins/modules/netbird_posture_check.py @@ -224,15 +224,23 @@ def find_posture_check_by_name(api, name): return None +def normalize_checks(checks): + """Normalize checks dict for comparison, removing None/null entries.""" + if not checks: + return {} + return {k: v for k, v in checks.items() if v is not None} + + def posture_check_needs_update(current, params): """Check if posture check needs to be updated.""" if params.get('name') is not None and current.get('name') != params['name']: return True - if params.get('description') is not None and current.get('description') != params['description']: - return True - # For checks, always update if provided to ensure they match exactly + if params.get('description') is not None: + if (current.get('description') or '') != (params['description'] or ''): + return True if params.get('checks') is not None: - return True + if normalize_checks(current.get('checks')) != normalize_checks(params['checks']): + return True return False diff --git a/plugins/modules/netbird_route.py b/plugins/modules/netbird_route.py index eaa5616..57921a0 100644 --- a/plugins/modules/netbird_route.py +++ b/plugins/modules/netbird_route.py @@ -197,10 +197,15 @@ def find_route_by_network_id(api, network_id): def route_needs_update(current, params): """Check if route needs to be updated.""" - check_fields = ['network', 'description', 'metric', 'masquerade', 'enabled', 'keep_route'] + check_fields = ['network', 'metric', 'masquerade', 'enabled', 'keep_route'] for field in check_fields: if params.get(field) is not None and current.get(field) != params[field]: return True + + # Check description (normalize None to '') + if params.get('description') is not None: + if (current.get('description') or '') != (params['description'] or ''): + return True # Check peer if params.get('peer_id') is not None and current.get('peer') != params['peer_id']: