From ce1dd0c78fcae19c76069729fb12adaaac57c452 Mon Sep 17 00:00:00 2001 From: umiruka <211638667+umiruka@users.noreply.github.com> Date: Mon, 2 Jun 2025 20:42:33 +0200 Subject: [PATCH] Use StrictVersion class to avoid wrong version comparisons that happen in some cases using LooseVersion class which results in TypeError (#10178) * Use StrictVersion class to avoid wrong version comparisons that happen in some cases using LooseVersion class * Refactor code * Add changelog for PR number 10178 * Update changelog to be more precise * Use LooseVersion instead of StrictVersion to check cobbler's version in cobbler system module * Update PR 10178 changelog description to be more accurate --- ...sion-number-to-avoid-wrong-comparisons-cobbler-xmlrpc.yml | 2 ++ plugins/modules/cobbler_system.py | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/10178-update-minimum-version-number-to-avoid-wrong-comparisons-cobbler-xmlrpc.yml diff --git a/changelogs/fragments/10178-update-minimum-version-number-to-avoid-wrong-comparisons-cobbler-xmlrpc.yml b/changelogs/fragments/10178-update-minimum-version-number-to-avoid-wrong-comparisons-cobbler-xmlrpc.yml new file mode 100644 index 0000000000..a5ffdadfdc --- /dev/null +++ b/changelogs/fragments/10178-update-minimum-version-number-to-avoid-wrong-comparisons-cobbler-xmlrpc.yml @@ -0,0 +1,2 @@ +bugfixes: + - cobbler_system - update minimum version number to avoid wrong comparisons that happen in some cases using LooseVersion class which results in TypeError (https://github.com/ansible-collections/community.general/issues/8506, https://github.com/ansible-collections/community.general/pull/10145, https://github.com/ansible-collections/community.general/pull/10178). diff --git a/plugins/modules/cobbler_system.py b/plugins/modules/cobbler_system.py index 207d4c6d40..83714dbc69 100644 --- a/plugins/modules/cobbler_system.py +++ b/plugins/modules/cobbler_system.py @@ -163,7 +163,6 @@ from ansible_collections.community.general.plugins.module_utils.datetime import ) from ansible_collections.community.general.plugins.module_utils.version import LooseVersion - IFPROPS_MAPPING = dict( bondingopts='bonding_opts', bridgeopts='bridge_opts', @@ -280,8 +279,8 @@ def main(): if system: # Update existing entry - system_id = None - if LooseVersion(str(conn.version())) >= LooseVersion('3.4.0'): + system_id = '' + if LooseVersion(str(conn.version())) >= LooseVersion('3.4'): system_id = conn.get_system_handle(name) else: system_id = conn.get_system_handle(name, token)