From 929136808f670fb58dd9c13d717a7099bc9257e9 Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Mon, 31 Jan 2022 08:28:00 +0330 Subject: [PATCH] gitlab: use gitlab instance runner to create runner (#3965) When using project it will use project level runner to create runner that based on python-gitlab it will be used for enabling runner and needs a runner_id so for creating a new runner it should use gitlab level runner Signed-off-by: Seena Fallah --- .../3935-use-gitlab-instance-runner-to-create-runner.yml | 2 ++ plugins/modules/source_control/gitlab/gitlab_runner.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/3935-use-gitlab-instance-runner-to-create-runner.yml diff --git a/changelogs/fragments/3935-use-gitlab-instance-runner-to-create-runner.yml b/changelogs/fragments/3935-use-gitlab-instance-runner-to-create-runner.yml new file mode 100644 index 0000000000..cbd61a88b1 --- /dev/null +++ b/changelogs/fragments/3935-use-gitlab-instance-runner-to-create-runner.yml @@ -0,0 +1,2 @@ +bugfixes: + - 'gitlab_runner - use correct API endpoint to create and retrieve project level runners when using ``project`` (https://github.com/ansible-collections/community.general/pull/3965).' diff --git a/plugins/modules/source_control/gitlab/gitlab_runner.py b/plugins/modules/source_control/gitlab/gitlab_runner.py index f57548a4a1..08c0f54bf7 100644 --- a/plugins/modules/source_control/gitlab/gitlab_runner.py +++ b/plugins/modules/source_control/gitlab/gitlab_runner.py @@ -248,7 +248,7 @@ class GitLabRunner(object): return True try: - runner = self._runners_endpoint.create(arguments) + runner = self._gitlab.runners.create(arguments) except (gitlab.exceptions.GitlabCreateError) as e: self._module.fail_json(msg="Failed to create runner: %s " % to_native(e)) @@ -292,10 +292,10 @@ class GitLabRunner(object): # object, so we need to handle both if hasattr(runner, "description"): if (runner.description == description): - return self._runners_endpoint.get(runner.id) + return self._gitlab.runners.get(runner.id) else: if (runner['description'] == description): - return self._runners_endpoint.get(runner['id']) + return self._gitlab.runners.get(runner['id']) ''' @param description Description of the runner