1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

[stable-11] Use Cobbler API version format to check version (#11045) (#11118)

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 6f11d75047)

Co-authored-by: Bruno Travouillon <devel@travouillon.fr>
This commit is contained in:
Felix Fontein 2025-11-12 06:59:31 +01:00 committed by GitHub
parent 4594f7cd18
commit 147ffc6b48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View file

@ -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).

View file

@ -161,7 +161,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',
@ -280,7 +279,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)