From b6c6253bfc8bd34e3f45ece1d3cb5df57d965214 Mon Sep 17 00:00:00 2001 From: Andreas Perhab Date: Thu, 1 Aug 2024 17:16:24 +0200 Subject: [PATCH] fix(modules/gitlab_runners): pass paused to gitlab (#8648) --- changelogs/fragments/8648-fix-gitlab-runner-paused.yaml | 2 ++ plugins/modules/gitlab_runner.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/8648-fix-gitlab-runner-paused.yaml diff --git a/changelogs/fragments/8648-fix-gitlab-runner-paused.yaml b/changelogs/fragments/8648-fix-gitlab-runner-paused.yaml new file mode 100644 index 0000000000..d064725f14 --- /dev/null +++ b/changelogs/fragments/8648-fix-gitlab-runner-paused.yaml @@ -0,0 +1,2 @@ +bugfixes: + - "gitlab_runner - fix ``paused`` parameter being ignored (https://github.com/ansible-collections/community.general/pull/8648)." \ No newline at end of file diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py index 96b3eb3fa4..b11e029103 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -466,6 +466,7 @@ def main(): state = module.params['state'] runner_description = module.params['description'] runner_active = module.params['active'] + runner_paused = module.params['paused'] tag_list = module.params['tag_list'] run_untagged = module.params['run_untagged'] runner_locked = module.params['locked'] @@ -500,7 +501,7 @@ def main(): module.exit_json(changed=False, msg="Runner deleted or does not exists") if state == 'present': - if gitlab_runner.create_or_update_runner(runner_description, { + runner_values = { "active": runner_active, "tag_list": tag_list, "run_untagged": run_untagged, @@ -510,7 +511,11 @@ def main(): "registration_token": registration_token, "group": group, "project": project, - }): + } + if LooseVersion(gitlab_runner._gitlab.version()[0]) >= LooseVersion("14.8.0"): + # the paused attribute for runners is available since 14.8 + runner_values["paused"] = runner_paused + if gitlab_runner.create_or_update_runner(runner_description, runner_values): module.exit_json(changed=True, runner=gitlab_runner.runner_object._attrs, msg="Successfully created or updated the runner %s" % runner_description) else: