From 7e666a9c319f3925dcdaa621c52de1155737e1a1 Mon Sep 17 00:00:00 2001 From: carlfriedrich Date: Sun, 19 Oct 2025 08:54:21 +0200 Subject: [PATCH] fix(modules/gitlab_runner): Fix exception in check mode on new runners (#10918) * fix(modules/gitlab_runner): Fix exception in check mode on new runners When a new runner is added in check mode, the role used to throw an exception. Fix this by returning a valid runner object instead of a boolean. Fixes #8854 * docs: Add changelog fragment --- changelogs/fragments/10918-gitlab-runner-fix-check-mode.yml | 2 ++ plugins/modules/gitlab_runner.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/10918-gitlab-runner-fix-check-mode.yml diff --git a/changelogs/fragments/10918-gitlab-runner-fix-check-mode.yml b/changelogs/fragments/10918-gitlab-runner-fix-check-mode.yml new file mode 100644 index 0000000000..214487938b --- /dev/null +++ b/changelogs/fragments/10918-gitlab-runner-fix-check-mode.yml @@ -0,0 +1,2 @@ +bugfixes: + - gitlab_runner - fix exception in check mode when a new runner is created (https://github.com/ansible-collections/community.general/issues/8854). diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py index 032f374b4e..889e2471cc 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -343,7 +343,10 @@ class GitLabRunner(object): ''' def create_runner(self, arguments): if self._module.check_mode: - return True + class MockRunner: + def __init__(self): + self._attrs = {} + return MockRunner() try: if arguments.get('token') is not None: