From 7a9253e68bdae1d7af693449f84bd7d859cfb541 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 18 May 2025 22:45:04 +0200 Subject: [PATCH] [PR #10145/3daa1dec backport][stable-9] Fix TypeError caused by giving more than 2 positional arguments to CobblerXMLRPCInterface.get_system_handle() (#10157) Fix TypeError caused by giving more than 2 positional arguments to CobblerXMLRPCInterface.get_system_handle() (#10145) * Update cobbler system module to also use new get_system_handle method definition * Add changelog for bug fix for cobbler system module (cherry picked from commit 3daa1dec0c2112446b733abf7b62121c63d32340) Co-authored-by: umiruka <211638667+umiruka@users.noreply.github.com> --- .../fragments/10145-fix-typeerror-cobbler-xmlrpc.yml | 2 ++ plugins/modules/cobbler_system.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/10145-fix-typeerror-cobbler-xmlrpc.yml diff --git a/changelogs/fragments/10145-fix-typeerror-cobbler-xmlrpc.yml b/changelogs/fragments/10145-fix-typeerror-cobbler-xmlrpc.yml new file mode 100644 index 0000000000..e2a9954ea1 --- /dev/null +++ b/changelogs/fragments/10145-fix-typeerror-cobbler-xmlrpc.yml @@ -0,0 +1,2 @@ +bugfixes: + - cobbler_system - fix bug with Cobbler >= 3.4.0 caused by giving more than 2 positional arguments to ``CobblerXMLRPCInterface.get_system_handle()`` (https://github.com/ansible-collections/community.general/issues/8506, https://github.com/ansible-collections/community.general/pull/10145). \ No newline at end of file diff --git a/plugins/modules/cobbler_system.py b/plugins/modules/cobbler_system.py index a327ede84b..e97d42ffac 100644 --- a/plugins/modules/cobbler_system.py +++ b/plugins/modules/cobbler_system.py @@ -162,6 +162,8 @@ 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', @@ -279,7 +281,11 @@ def main(): if system: # Update existing entry - system_id = conn.get_system_handle(name, token) + system_id = None + if LooseVersion(str(conn.version())) >= LooseVersion('3.4.0'): + system_id = conn.get_system_handle(name) + else: + system_id = conn.get_system_handle(name, token) for key, value in iteritems(module.params['properties']): if key not in system: