[PATCH 04/26] scripts/ci: update the gitlab-runner playbook

Alex Bennée posted 26 patches 2 months, 2 weeks ago
[PATCH 04/26] scripts/ci: update the gitlab-runner playbook
Posted by Alex Bennée 2 months, 2 weeks ago
The upstream install instructions:

  https://docs.gitlab.com/runner/install/linux-repository.html

Now refer to repositories and a setup script. Modernise the playbook
to use the preferred delivery method.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 scripts/ci/setup/gitlab-runner.yml | 39 +++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/scripts/ci/setup/gitlab-runner.yml b/scripts/ci/setup/gitlab-runner.yml
index 7bdafab511..57e7faebf1 100644
--- a/scripts/ci/setup/gitlab-runner.yml
+++ b/scripts/ci/setup/gitlab-runner.yml
@@ -49,30 +49,51 @@
     - debug:
         msg: gitlab-runner arch is {{ gitlab_runner_arch }}
 
-    - name: Download the matching gitlab-runner (DEB)
+    # Debian/Ubuntu setup
+    - name: Get gitlab-runner repo setup script (DEB)
       get_url:
         dest: "/root/"
-        url: "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_{{ gitlab_runner_arch }}.deb"
+        url: "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh"
+        mode: 0755
       when:
         - ansible_facts['distribution'] == 'Ubuntu'
 
-    - name: Download the matching gitlab-runner (RPM)
+    - name: Run gitlab-runner repo setup script (DEB)
+      shell: "/root/script.deb.sh"
+      when:
+        - ansible_facts['distribution'] == 'Ubuntu'
+
+    - name: Install gitlab-runner (DEB)
+      ansible.builtin.apt:
+          name: gitlab-runner
+          update_cache: yes
+          state: present
+      when:
+        - ansible_facts['distribution'] == 'Ubuntu'
+
+    # RPM setup
+    - name: Get gitlab-runner repo setup script (RPM)
       get_url:
         dest: "/root/"
-        url: "https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_{{ gitlab_runner_arch }}.rpm"
+        url: "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh"
+        mode: 0755
       when:
         - ansible_facts['distribution'] == 'CentOS'
 
-    - name: Install gitlab-runner via package manager (DEB)
-      apt: deb="/root/gitlab-runner_{{ gitlab_runner_arch }}.deb"
+    - name: Run gitlab-runner repo setup script (RPM)
+      shell: "/root/script.rpm.sh"
       when:
-        - ansible_facts['distribution'] == 'Ubuntu'
+        - ansible_facts['distribution'] == 'CentOS'
 
-    - name: Install gitlab-runner via package manager (RPM)
-      yum: name="/root/gitlab-runner_{{ gitlab_runner_arch }}.rpm"
+    - name: Install gitlab-runner (RPM)
+      yum:
+        name: gitlab-runner
+        update_cache: yes
+        state: present
       when:
         - ansible_facts['distribution'] == 'CentOS'
 
+    # Register Runners
     - name: Register the gitlab-runner
       command: "/usr/bin/gitlab-runner register --non-interactive --url {{ gitlab_runner_server_url }} --registration-token {{ gitlab_runner_registration_token }} --executor shell --tag-list {{ ansible_facts[\"architecture\"] }},{{ ansible_facts[\"distribution\"]|lower }}_{{ ansible_facts[\"distribution_version\"] }} --description '{{ ansible_facts[\"distribution\"] }} {{ ansible_facts[\"distribution_version\"] }} {{ ansible_facts[\"architecture\"] }} ({{ ansible_facts[\"os_family\"] }})'"
 
-- 
2.39.2
Re: [PATCH 04/26] scripts/ci: update the gitlab-runner playbook
Posted by Pierrick Bouvier 2 months, 2 weeks ago
On 9/10/24 07:07, Alex Bennée wrote:
> The upstream install instructions:
> 
>    https://docs.gitlab.com/runner/install/linux-repository.html
> 
> Now refer to repositories and a setup script. Modernise the playbook
> to use the preferred delivery method.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   scripts/ci/setup/gitlab-runner.yml | 39 +++++++++++++++++++++++-------
>   1 file changed, 30 insertions(+), 9 deletions(-)
> 
> diff --git a/scripts/ci/setup/gitlab-runner.yml b/scripts/ci/setup/gitlab-runner.yml
> index 7bdafab511..57e7faebf1 100644
> --- a/scripts/ci/setup/gitlab-runner.yml
> +++ b/scripts/ci/setup/gitlab-runner.yml
> @@ -49,30 +49,51 @@
>       - debug:
>           msg: gitlab-runner arch is {{ gitlab_runner_arch }}
>   
> -    - name: Download the matching gitlab-runner (DEB)
> +    # Debian/Ubuntu setup
> +    - name: Get gitlab-runner repo setup script (DEB)
>         get_url:
>           dest: "/root/"
> -        url: "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_{{ gitlab_runner_arch }}.deb"
> +        url: "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh"
> +        mode: 0755
>         when:
>           - ansible_facts['distribution'] == 'Ubuntu'
>   
> -    - name: Download the matching gitlab-runner (RPM)
> +    - name: Run gitlab-runner repo setup script (DEB)
> +      shell: "/root/script.deb.sh"
> +      when:
> +        - ansible_facts['distribution'] == 'Ubuntu'
> +
> +    - name: Install gitlab-runner (DEB)
> +      ansible.builtin.apt:
> +          name: gitlab-runner
> +          update_cache: yes
> +          state: present
> +      when:
> +        - ansible_facts['distribution'] == 'Ubuntu'
> +
> +    # RPM setup
> +    - name: Get gitlab-runner repo setup script (RPM)
>         get_url:
>           dest: "/root/"
> -        url: "https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_{{ gitlab_runner_arch }}.rpm"
> +        url: "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh"
> +        mode: 0755
>         when:
>           - ansible_facts['distribution'] == 'CentOS'
>   
> -    - name: Install gitlab-runner via package manager (DEB)
> -      apt: deb="/root/gitlab-runner_{{ gitlab_runner_arch }}.deb"
> +    - name: Run gitlab-runner repo setup script (RPM)
> +      shell: "/root/script.rpm.sh"
>         when:
> -        - ansible_facts['distribution'] == 'Ubuntu'
> +        - ansible_facts['distribution'] == 'CentOS'
>   
> -    - name: Install gitlab-runner via package manager (RPM)
> -      yum: name="/root/gitlab-runner_{{ gitlab_runner_arch }}.rpm"
> +    - name: Install gitlab-runner (RPM)
> +      yum:
> +        name: gitlab-runner
> +        update_cache: yes
> +        state: present
>         when:
>           - ansible_facts['distribution'] == 'CentOS'
>   
> +    # Register Runners
>       - name: Register the gitlab-runner
>         command: "/usr/bin/gitlab-runner register --non-interactive --url {{ gitlab_runner_server_url }} --registration-token {{ gitlab_runner_registration_token }} --executor shell --tag-list {{ ansible_facts[\"architecture\"] }},{{ ansible_facts[\"distribution\"]|lower }}_{{ ansible_facts[\"distribution_version\"] }} --description '{{ ansible_facts[\"distribution\"] }} {{ ansible_facts[\"distribution_version\"] }} {{ ansible_facts[\"architecture\"] }} ({{ ansible_facts[\"os_family\"] }})'"
>   

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>