Skip to content

Commit

Permalink
Install fleeting-plugin-openstack directly from GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashuste committed Aug 9, 2024
1 parent 8ef1bb3 commit 10eba14
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
4 changes: 4 additions & 0 deletions roles/gitlab_runner/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
52 changes: 44 additions & 8 deletions roles/gitlab_runner/tasks/install.autoscaler-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions roles/gitlab_runner/tasks/install.debianlike.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- "debian-archive-keyring"
- "apt-transport-https"
- "gnupg"
- "binutils"
state: "present"
update_cache: true

Expand Down

0 comments on commit 10eba14

Please sign in to comment.