From e757adbfca71600088bda345c5dceaed34f935b6 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 19 Oct 2025 09:31:24 +0200 Subject: [PATCH] [PR #10918/7e666a9c backport][stable-11] fix(modules/gitlab_runner): Fix exception in check mode on new runners (#10944) 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 (cherry picked from commit 7e666a9c319f3925dcdaa621c52de1155737e1a1) Co-authored-by: carlfriedrich --- 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 87ba152ffa..864f237d87 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -345,7 +345,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: