-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
bugThis issue/PR relates to a bugThis issue/PR relates to a bugmodulemodulemodulepluginsplugin (any type)plugin (any type)traceback
Description
Summary
When running the task below against Cobbler 3.3.7 API for an existing system, it fails with:
TASK [Ensure the system exists in Cobbler] ************************************************************************************************************************************************************************
Saturday 08 November 2025 00:58:54 +0000 (0:00:00.023) 0:00:00.037 *****
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: xmlrpc.client.Fault: <Fault 1: "<class 'TypeError'>:CobblerXMLRPCInterface.get_system_handle() missing 1 required positional argument: 'token'">
fatal: [slurm1 -> localhost]: FAILED! => changed=false
module_stderr: |-
Traceback (most recent call last):
File "/home/mistral/.ansible/tmp/ansible-tmp-1762563534.5609677-88660-7181109980747/AnsiballZ_cobbler_system.py", line 107, in <module>
_ansiballz_main()
File "/home/mistral/.ansible/tmp/ansible-tmp-1762563534.5609677-88660-7181109980747/AnsiballZ_cobbler_system.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/mistral/.ansible/tmp/ansible-tmp-1762563534.5609677-88660-7181109980747/AnsiballZ_cobbler_system.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.cobbler_system', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.cobbler_system', _modlib_path=modlib_path),
File "<frozen runpy>", line 226, in run_module
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/tmp/ansible_community.general.cobbler_system_payload_d1vbqwmh/ansible_community.general.cobbler_system_payload.zip/ansible_collections/community/general/plugins/modules/cobbler_system.py", line 357, in <module>
File "/tmp/ansible_community.general.cobbler_system_payload_d1vbqwmh/ansible_community.general.cobbler_system_payload.zip/ansible_collections/community/general/plugins/modules/cobbler_system.py", line 286, in main
File "/usr/lib/python3.12/xmlrpc/client.py", line 1122, in __call__
return self.__send(self.__name, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/xmlrpc/client.py", line 1461, in __request
response = self.__transport.request(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/xmlrpc/client.py", line 1166, in request
return self.single_request(host, handler, request_body, verbose)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/xmlrpc/client.py", line 1182, in single_request
return self.parse_response(resp)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/xmlrpc/client.py", line 1351, in parse_response
return u.close()
^^^^^^^^^
File "/usr/lib/python3.12/xmlrpc/client.py", line 668, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 1: "<class 'TypeError'>:CobblerXMLRPCInterface.get_system_handle() missing 1 required positional argument: 'token'">
module_stdout: ''
msg: |-
MODULE FAILURE: No start of json char found
See stdout/stderr for the exact error
rc: 1
This relates to these 2 changes:
- Fix TypeError caused by giving more than 2 positional arguments to CobblerXMLRPCInterface.get_system_handle() #10145
- Use StrictVersion class to avoid wrong version comparisons that happen in some cases using LooseVersion class which results in TypeError #10178
The code seems to assume that the version returned from the API is X.Y.Z, but it is not.
https://github.com/cobbler/cobbler/blob/v3.3.7/cobbler/api.py#L274-L277
elems = data["version_tuple"]
# This double conversion is required because of the typical floating point problems.
# https://docs.python.org/3/tutorial/floatingpoint.html
return float(format(int(elems[0]) + 0.1 * int(elems[1]) + 0.001 * int(elems[2]), '.3f'))
For version 3.3.7, the version() returns 3 + 0.3 + 0.007 = 3.307.
This is confirmed with the debug below in the module:
if system:
# Update existing entry
system_id = ''
if LooseVersion(str(conn.version())) >= LooseVersion('3.4'):
module.warn("DEBUG#2 version='{0}'".format(conn.version()))
system_id = conn.get_system_handle(name)
Nov 08 00:46:17 bbtemp ansible-community.general.cobbler_system[88573]: [WARNING] DEBUG#2 version='3.307'
The logic is broken:
>>> from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
>>> LooseVersion('3.307') >= LooseVersion('3.4')
True
>>> LooseVersion('3.307') >= LooseVersion('3.4.0')
True
The test should be:
>>> LooseVersion('3.307') >= LooseVersion('3.400')
False
Issue Type
Bug Report
Component Name
cobbler_system
Ansible Version
$ ansible --version
ansible [core 2.18.11]
config file = /store/ansible/ansible.cfg
configured module search path = ['/home/mistral/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /store/ansible/venv-ansible/lib/python3.12/site-packages/ansible
ansible collection location = /store/ansible/galaxy
executable location = /store/ansible/venv-ansible/bin/ansible
python version = 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] (/store/ansible/venv-ansible/bin/python3)
jinja version = 3.1.6
libyaml = TrueCommunity.general Version
$ ansible-galaxy collection list community.general
Collection Version
----------------- -------
community.general 10.7.6Configuration
$ ansible-config dump --only-changed
ANSIBLE_NOCOWS(/store/ansible/ansible.cfg) = True
CALLBACKS_ENABLED(/store/ansible/ansible.cfg) = ['ansible.posix.profile_tasks', 'ansible.posix.timer']
COLLECTIONS_PATHS(/store/ansible/ansible.cfg) = ['/store/ansible/galaxy']
CONFIG_FILE() = /store/ansible/ansible.cfg
DEFAULT_FORKS(/store/ansible/ansible.cfg) = 40
DEFAULT_ROLES_PATH(/store/ansible/ansible.cfg) = ['/store/ansible/galaxy/roles']
DEFAULT_STDOUT_CALLBACK(/store/ansible/ansible.cfg) = community.general.yaml
EDITOR(env: EDITOR) = vim
INVENTORY_IGNORE_PATTERNS(/store/ansible/ansible.cfg) = ['docs/*', 'files/*', 'templates/*']OS / Environment
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
# cobbler --version
Cobbler 3.3.7
source: 758143e, Sun Nov 17 22:02:02 2024 +0100
build time: Mon Oct 27 22:21:51 2025
Steps to Reproduce
Expected Results
I expect the module to succeed, not fail.
Actual Results
Use module cobbler_system against 3.3..7 with state: present.
Code of Conduct
- I agree to follow the Ansible Code of Conduct
Metadata
Metadata
Assignees
Labels
bugThis issue/PR relates to a bugThis issue/PR relates to a bugmodulemodulemodulepluginsplugin (any type)plugin (any type)traceback