Skip to content

Commit 74bc455

Browse files
authored
Merge pull request #303 from tobiashuste/fleeting-plugin-from-github
Install fleeting-plugin-openstack directly from GitHub
2 parents 8ef1bb3 + dbdb997 commit 74bc455

File tree

6 files changed

+98
-31
lines changed

6 files changed

+98
-31
lines changed

molecule/gitlab_runner/molecule.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,19 @@ provisioner:
7575
gitlab_runner_registry_mirror: "https://registry-mirror.example"
7676
gitlab_runner_listen_address: "127.0.0.1:9252"
7777
gitlab_runner_set_default_network_opts: true
78+
gitlab_runner_autoscaler_openstack_auth_url: "https://openstack.helmholtz.de:5000"
79+
gitlab_runner_autoscaler_openstack_username: "openstackuser"
80+
gitlab_runner_autoscaler_openstack_password: "123456"
81+
gitlab_runner_autoscaler_openstack_project_id: "e5cc8263-be6c-45a7-a6ce-e852dac95395"
82+
gitlab_runner_autoscaler_openstack_project_name: "openstack-project"
83+
gitlab_runner_autoscaler_openstack_user_domain_name: "Default"
84+
gitlab_runner_autoscaler_openstack_region_name: "Default"
7885
gitlab_runner_list:
7986
- name: "test01"
8087
url: "https://gitlab.com"
8188
description: "Molecule test runner"
8289
authentication_token: "${AUTHENTICATION_TOKEN}"
83-
executor: "docker+machine"
90+
executor: "docker-autoscaler"
8491
environment: ["CI_CPUS=8", "DOCKER_TLS_CERTDIR=/certs"]
8592
docker_volumes: ["/cache", "/certs/client", "/opt/docker/daemon.json:/etc/docker/daemon.json:ro"]
8693
docker_image: "python:3.8"
@@ -89,28 +96,21 @@ provisioner:
8996
tags: ["docker", "hifis"]
9097
locked: true
9198
limit: 10
99+
autoscaler_max_builds: 1
100+
autoscaler_idle_count: 5
101+
autoscaler_max_instances: 10
92102
machine_idle_count: 5
93-
machine_idle_time: 7200
94-
machine_max_builds: 4
95-
machine_max_growth_rate: 2
96-
machine_driver: "openstack"
97-
machine_name: "auto-scale-%s"
98-
machine_options:
99-
- "openstack-auth-url=https://openstack.example:5000/v3"
100-
- "openstack-image-id=73f07dd3-fa8b-468f-b6bc-b0cd4510f5d0"
101-
- "openstack-flavor-name=m1.small"
102-
- "openstack-net-id=7834deeb-8bd5-4fc7-b35b-24035d8f47a7"
103-
- "openstack-username=gitlab-runner"
104-
- "openstack-password=secret"
105-
- "openstack-tenant-id=123456"
106-
- "openstack-domain-name=default"
107-
- "openstack-ssh-user=core"
108-
- "openstack-sec-groups=Internal"
109-
- "openstack-keypair-name=runners-internal"
110-
- "openstack-private-key-file=/etc/gitlab-runner/gitlab_runner_key"
111-
- "openstack-user-data-file=/etc/gitlab-runner/ignition.json"
112-
- "openstack-active-timeout=300"
113-
- "engine-registry-mirror=https://registry-mirror.example"
103+
autoscaler_group_name: "hifis"
104+
autoscaler_cloud_name: "openstack"
105+
autoscaler_clouds_config: "/etc/gitlab-runner/clouds.yaml"
106+
autoscaler_use_ignition: true
107+
autoscaler_flavor_ref: "a7779e0c-899a-4c73-b75d-757e7722dc9b"
108+
autoscaler_image_ref: "67c1e69a-921d-4a5c-85cf-cf2a7d94a14d"
109+
autoscaler_network_id: "183bd5c6-e720-4601-b471-f4135a32263d"
110+
autoscaler_security_group: "8f291fca-006c-4576-a18e-f343d06af2c4"
111+
autoscaler_scheduler_hint: "8357bc97-580a-429f-a71d-895a3ab4b645"
112+
autoscaler_username: "core"
113+
autoscaler_keyname: "runner-internal"
114114
cache_type: "s3"
115115
cache_server_address: "https://cache.example"
116116
cache_access_key: "key"

molecule/gitlab_runner/verify.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@
4040
when: "gitlab_runner_list | selectattr('executor', 'equalto', 'docker+machine') | list | length > 0"
4141
failed_when: "'0.16.2-gitlab.25' not in machine_version.stdout"
4242

43+
- name: "Identify installed fleeting plugins"
44+
ansible.builtin.command: "gitlab-runner fleeting list"
45+
register: "fleeting_cmd"
46+
changed_when: false
47+
48+
- name: "Assert that fleeting-plugin-openstack is installed"
49+
when: "gitlab_runner_list | selectattr('executor', 'equalto', 'docker-autoscaler') | list | length > 0"
50+
ansible.builtin.assert:
51+
that:
52+
- "'fleeting-plugin-openstack' in fleeting_cmd.stdout"
53+
4354
- name: "Assert that Gitlab-Runner is installed"
4455
ansible.builtin.assert:
4556
that:

roles/gitlab_runner/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ gitlab_runner_enable_session_server: false
4545
gitlab_runner_session_server_listen_address: "0.0.0.0:8093"
4646
gitlab_runner_session_server_advertise_address: "{{ gitlab_runner_session_server_listen_address }}"
4747
gitlab_runner_session_server_timeout: 1800
48+
49+
gitlab_runner_autoscaler_plugin_version: "0.21.1"
50+
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"
51+
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"

roles/gitlab_runner/tasks/install.autoscaler-plugin.yml

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,62 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
---
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
1462

1563
- name: "Place clouds.yaml template"
1664
ansible.builtin.template:

roles/gitlab_runner/tasks/install.debianlike.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- "debian-archive-keyring"
1212
- "apt-transport-https"
1313
- "gnupg"
14+
- "binutils"
1415
state: "present"
1516
update_cache: true
1617

roles/gitlab_runner/tasks/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
ansible.builtin.slurp:
5252
src: "/etc/gitlab-runner/ignition.json"
5353
register: "ignition_json"
54-
when: "gitlab_runner_install_autoscaler"
54+
when:
55+
- "gitlab_runner_install_autoscaler"
56+
- "not gitlab_runner_is_initial_dryrun"
5557

5658
- name: "Template config file"
5759
ansible.builtin.template:
@@ -64,6 +66,7 @@
6466
no_log: true
6567
vars:
6668
ignition_content: "{{ ignition_json['content'] | b64decode }}"
69+
when: "not gitlab_runner_is_initial_dryrun"
6770

6871
- name: "Start GitLab-Runner"
6972
ansible.builtin.service:

0 commit comments

Comments
 (0)