From c573891160ca7df5eccc460c0b478b14ca37588b Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 06:54:04 +0100 Subject: [PATCH] [PR #11045/6f11d750 backport][stable-12] Use Cobbler API version format to check version (#11117) Use Cobbler API version format to check version (#11045) * Use Cobbler API version format to check version Cobbler use the formula below to return the version: float(format(int(elems[0]) + 0.1 * int(elems[1]) + 0.001 * int(elems[2]), '.3f')) Which means that 3.3.7 is changed to 3.307 which is > 3.4. * Compare Cobbler version as a float * Remove LooseVersion import (cherry picked from commit 6f11d750472c0d791ab46b755faa455caf18cc61) Co-authored-by: Bruno Travouillon --- changelogs/fragments/11045-check-cobbler-version.yml | 2 ++ plugins/modules/cobbler_system.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/11045-check-cobbler-version.yml diff --git a/changelogs/fragments/11045-check-cobbler-version.yml b/changelogs/fragments/11045-check-cobbler-version.yml new file mode 100644 index 0000000000..46483c40c7 --- /dev/null +++ b/changelogs/fragments/11045-check-cobbler-version.yml @@ -0,0 +1,2 @@ +bugfixes: + - cobbler_system - compare the version as a float which is the type returned by the Cobbler API (https://github.com/ansible-collections/community.general/issues/11044). diff --git a/plugins/modules/cobbler_system.py b/plugins/modules/cobbler_system.py index a889d09058..3662b2ac3a 100644 --- a/plugins/modules/cobbler_system.py +++ b/plugins/modules/cobbler_system.py @@ -156,7 +156,6 @@ from ansible.module_utils.common.text.converters import to_text from ansible_collections.community.general.plugins.module_utils.datetime import ( now, ) -from ansible_collections.community.general.plugins.module_utils.version import LooseVersion IFPROPS_MAPPING = dict( bondingopts="bonding_opts", @@ -266,7 +265,8 @@ def main(): if system: # Update existing entry system_id = "" - if LooseVersion(str(conn.version())) >= LooseVersion("3.4"): + # https://github.com/cobbler/cobbler/blame/v3.3.7/cobbler/api.py#L277 + if float(conn.version()) >= 3.4: system_id = conn.get_system_handle(name) else: system_id = conn.get_system_handle(name, token)