From 4c22e66e6ec14345474bbb030fc2c3408852c596 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Sun, 19 Feb 2023 13:09:54 +0100 Subject: [PATCH] Update: will now register runner using non-deprecated token method --- group_vars/ci-runners.yml.example | 5 ++--- inventory.yml | 5 ++--- roles/gitlab-runner/tasks/main.yml | 21 +++++++++++++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/group_vars/ci-runners.yml.example b/group_vars/ci-runners.yml.example index 438e6ea..7943319 100644 --- a/group_vars/ci-runners.yml.example +++ b/group_vars/ci-runners.yml.example @@ -1,7 +1,6 @@ runner: gitlab_url: 'https://gitlab.geant.org/' + git_project_name: 'nat/gap' access_token: xxx registration_token: xxx - runner_tags: - - gap - - nat + executor: shell diff --git a/inventory.yml b/inventory.yml index 164ce38..2b6b690 100644 --- a/inventory.yml +++ b/inventory.yml @@ -1,5 +1,4 @@ ci-runners: hosts: - test-nat-ci01: - ansible_host: - test-nat-ci01 + nat-runner-01: + ansible_host: nat-runner-01 diff --git a/roles/gitlab-runner/tasks/main.yml b/roles/gitlab-runner/tasks/main.yml index 097aa00..997fbf9 100644 --- a/roles/gitlab-runner/tasks/main.yml +++ b/roles/gitlab-runner/tasks/main.yml @@ -18,17 +18,30 @@ ansible.builtin.pip: name: python-gitlab -- name: Register runner - no_log: true +- name: Request runner token community.general.gitlab_runner: api_url: '{{ runner.gitlab_url }}' api_token: '{{ runner.access_token }}' registration_token: '{{ runner.registration_token }}' description: '{{ inventory_hostname_short }}' - project: 'nat/gap' + project: '{{ runner.git_project_name }}' state: present - tag_list: '{{ runner.runner_tags + [inventory_hostname_short] }}' + tag_list: '{{ runner.executor }}-executor' run_untagged: false locked: true access_level_on_creation: true access_level: 'not_protected' + no_log: true + register: gitlab_authentication_response + +- name: Register GitLab + ansible.builtin.command: + argv: + - gitlab-runner + - register + - '--url={{ runner.gitlab_url }}' + - '--token={{ gitlab_authentication_response.runner.token }}' + - '--executor={{ runner.executor }}' + - '--non-interactive' + become: true + no_log: true -- GitLab