From 10eba14e1215bf4b6487ecc1f8a511be39ae9fb9 Mon Sep 17 00:00:00 2001 From: Tobias Huste Date: Fri, 9 Aug 2024 10:03:01 +0200 Subject: [PATCH] Install fleeting-plugin-openstack directly from GitHub --- roles/gitlab_runner/defaults/main.yml | 4 ++ .../tasks/install.autoscaler-plugin.yml | 52 ++++++++++++++++--- .../tasks/install.debianlike.yml | 1 + 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/roles/gitlab_runner/defaults/main.yml b/roles/gitlab_runner/defaults/main.yml index 2c5c3ff..4b11212 100644 --- a/roles/gitlab_runner/defaults/main.yml +++ b/roles/gitlab_runner/defaults/main.yml @@ -45,3 +45,7 @@ gitlab_runner_enable_session_server: false gitlab_runner_session_server_listen_address: "0.0.0.0:8093" gitlab_runner_session_server_advertise_address: "{{ gitlab_runner_session_server_listen_address }}" gitlab_runner_session_server_timeout: 1800 + +gitlab_runner_autoscaler_plugin_version: "0.21.1" +gitlab_runner_autoscaler_plugin_url: "https://github.com/sardinasystems/fleeting-plugin-openstack/releases/download/{{ gitlab_runner_autoscaler_plugin_version }}/fleeting-plugin-openstack_{{ gitlab_runner_autoscaler_plugin_version }}_linux_amd64.tar.gz" +gitlab_runner_autoscaler_plugin_checksumfile: "https://github.com/sardinasystems/fleeting-plugin-openstack/releases/download/{{ gitlab_runner_autoscaler_plugin_version }}/fleeting-plugin-openstack_{{ gitlab_runner_autoscaler_plugin_version }}_sha512-checksums.txt" diff --git a/roles/gitlab_runner/tasks/install.autoscaler-plugin.yml b/roles/gitlab_runner/tasks/install.autoscaler-plugin.yml index dbec49f..ae46b30 100644 --- a/roles/gitlab_runner/tasks/install.autoscaler-plugin.yml +++ b/roles/gitlab_runner/tasks/install.autoscaler-plugin.yml @@ -3,14 +3,50 @@ # SPDX-License-Identifier: Apache-2.0 --- -- name: "Download and install autoscaler plugin" - ansible.builtin.get_url: - url: "{{ gitlab_runner_autoscaler_plugin_url }}" - dest: "/usr/local/bin/fleeting-plugin-openstack" - checksum: "{{ gitlab_runner_autoscaler_plugin_checksum }}" - mode: '0755' - owner: "root" - group: "root" + +- name: "Check version of installed fleeting plugin" + ansible.builtin.command: 'strings /usr/local/bin/fleeting-plugin-openstack | grep -oP "(?<=fleeting-plugin-openstack.Version=)(\d+\.\d+\.\d+)" | head -n 1' + register: "_fleeting_plugin_version_installed" + changed_when: false + check_mode: false + +- name: "Download and install fleeting plugin" + when: "_fleeting_plugin_version_installed != gitlab_runner_autoscaler_plugin_version" + block: + - name: "Create temporary directory" + ansible.builtin.tempfile: + state: "directory" + register: "tempdir_fleeting_plugin" + check_mode: false + changed_when: false + + - name: "Download fleeting-plugin-openstack" + ansible.builtin.get_url: + url: "{{ gitlab_runner_autoscaler_plugin_url }}" + dest: "{{ (tempdir_fleeting_plugin.path, 'fleeting-plugin-openstack.tar.gz') | path_join }}" + checksum: "sha512:{{ gitlab_runner_autoscaler_plugin_checksumfile }}" + owner: "root" + group: "root" + mode: "0600" + check_mode: false + + - name: "Extract fleeting-plugin-openstack binary" + ansible.builtin.unarchive: + src: "{{ (tempdir_fleeting_plugin.path, 'fleeting-plugin-openstack.tar.gz') | path_join }}" + dest: "/usr/local/bin" + include: + - "bin/fleeting-plugin-openstack" + owner: "root" + group: "root" + mode: "0755" + + always: + - name: "Remove temporary directory" + ansible.builtin.file: + path: "{{ tempdir_fleeting_plugin.path }}" + state: "absent" + check_mode: false + changed_when: false - name: "Place clouds.yaml template" ansible.builtin.template: diff --git a/roles/gitlab_runner/tasks/install.debianlike.yml b/roles/gitlab_runner/tasks/install.debianlike.yml index 21da01d..cf8bf12 100644 --- a/roles/gitlab_runner/tasks/install.debianlike.yml +++ b/roles/gitlab_runner/tasks/install.debianlike.yml @@ -11,6 +11,7 @@ - "debian-archive-keyring" - "apt-transport-https" - "gnupg" + - "binutils" state: "present" update_cache: true