|
3 | 3 | # SPDX-License-Identifier: Apache-2.0 |
4 | 4 |
|
5 | 5 | --- |
6 | | -- name: "Download and install autoscaler plugin" |
7 | | - ansible.builtin.get_url: |
8 | | - url: "{{ gitlab_runner_autoscaler_plugin_url }}" |
9 | | - dest: "/usr/local/bin/fleeting-plugin-openstack" |
10 | | - checksum: "{{ gitlab_runner_autoscaler_plugin_checksum }}" |
11 | | - mode: '0755' |
12 | | - owner: "root" |
13 | | - group: "root" |
| 6 | + |
| 7 | +- name: "Check if fleeting-plugin-openstack is installed" |
| 8 | + ansible.builtin.stat: |
| 9 | + path: "/usr/local/bin/fleeting-plugin-openstack" |
| 10 | + register: "_fleeting_plugin_openstack_stat" |
| 11 | + |
| 12 | +- name: "Check version of installed fleeting plugin" |
| 13 | + when: "_fleeting_plugin_openstack_stat.stat.exists" |
| 14 | + ansible.builtin.shell: |
| 15 | + cmd: | |
| 16 | + set -o pipefail |
| 17 | + strings /usr/local/bin/fleeting-plugin-openstack | grep -oP "(?<=fleeting-plugin-openstack.Version=)(\d+\.\d+\.\d+)" | head -n 1 |
| 18 | + executable: "/bin/bash" |
| 19 | + register: "_fleeting_plugin_version_installed" |
| 20 | + changed_when: false |
| 21 | + check_mode: false |
| 22 | + |
| 23 | +- name: "Download and install fleeting plugin" |
| 24 | + when: "not _fleeting_plugin_openstack_stat.stat.exists or _fleeting_plugin_version_installed.stdout != gitlab_runner_autoscaler_plugin_version" |
| 25 | + block: |
| 26 | + - name: "Create temporary directory" |
| 27 | + ansible.builtin.tempfile: |
| 28 | + state: "directory" |
| 29 | + register: "tempdir_fleeting_plugin" |
| 30 | + check_mode: false |
| 31 | + changed_when: false |
| 32 | + |
| 33 | + - name: "Download fleeting-plugin-openstack" |
| 34 | + ansible.builtin.get_url: |
| 35 | + url: "{{ gitlab_runner_autoscaler_plugin_url }}" |
| 36 | + dest: "{{ (tempdir_fleeting_plugin.path, 'fleeting-plugin-openstack.tar.gz') | path_join }}" |
| 37 | + checksum: "sha512:{{ gitlab_runner_autoscaler_plugin_checksumfile }}" |
| 38 | + owner: "root" |
| 39 | + group: "root" |
| 40 | + mode: "0600" |
| 41 | + check_mode: false |
| 42 | + |
| 43 | + - name: "Extract fleeting-plugin-openstack binary" |
| 44 | + ansible.builtin.unarchive: |
| 45 | + src: "{{ (tempdir_fleeting_plugin.path, 'fleeting-plugin-openstack.tar.gz') | path_join }}" |
| 46 | + dest: "/usr/local/bin/" |
| 47 | + include: |
| 48 | + - "bin/fleeting-plugin-openstack" |
| 49 | + owner: "root" |
| 50 | + group: "root" |
| 51 | + mode: "0755" |
| 52 | + remote_src: true |
| 53 | + extra_opts: ['--strip-components=1'] |
| 54 | + |
| 55 | + always: |
| 56 | + - name: "Remove temporary directory" |
| 57 | + ansible.builtin.file: |
| 58 | + path: "{{ tempdir_fleeting_plugin.path }}" |
| 59 | + state: "absent" |
| 60 | + check_mode: false |
| 61 | + changed_when: false |
14 | 62 |
|
15 | 63 | - name: "Place clouds.yaml template" |
16 | 64 | ansible.builtin.template: |
|
0 commit comments