Skip to content

Commit 7c14225

Browse files
authored
Merge pull request #216 from tobiashuste/210-include-hifisgitlab_runner-role-into-collection
Integrate gitlab_runner role into hifis toolkit
2 parents 9d30d91 + 3d5f72e commit 7c14225

35 files changed

+2147
-30
lines changed

.github/labeler.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ keepalived:
1010
- "roles/keepalived/**"
1111
- "molecule/keepalived/**"
1212
- ".github/workflows/keepalived.yml"
13+
gitlab_runner:
14+
- changed-files:
15+
- any-glob-to-any-file:
16+
- "roles/gitlab_runner/**"
17+
- "molecule/gitlab_runner/**"
18+
- ".github/workflows/gitlab_runner.yml"
1319
ssh_keys:
1420
- changed-files:
1521
- any-glob-to-any-file:

.github/workflows/gitlab_runner.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
name: "hifis.toolkit.gitlab_runner"
8+
9+
on:
10+
pull_request:
11+
paths:
12+
- '.github/workflows/gitlab_runner.yml'
13+
- 'roles/gitlab_runner/**'
14+
- 'molecule/gitlab_runner/**'
15+
- 'Pipfile'
16+
- 'Pipfile.lock'
17+
push:
18+
branches:
19+
- "main"
20+
tags:
21+
- "v*.*.*"
22+
paths:
23+
- '.github/workflows/gitlab_runner.yml'
24+
- 'roles/gitlab_runner/**'
25+
- 'molecule/gitlab_runner/**'
26+
- 'Pipfile'
27+
- 'Pipfile.lock'
28+
schedule:
29+
- cron: "0 0 * * *"
30+
env:
31+
PY_COLORS: 1
32+
ANSIBLE_FORCE_COLOR: 1
33+
34+
jobs:
35+
36+
test:
37+
name: "Run Molecule tests."
38+
runs-on: "ubuntu-24.04"
39+
env:
40+
PY_COLORS: 1
41+
ANSIBLE_FORCE_COLOR: 1
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
image:
46+
- "ghcr.io/hifis-net/ubuntu-systemd:20.04"
47+
- "ghcr.io/hifis-net/ubuntu-systemd:22.04"
48+
- "ghcr.io/hifis-net/ubuntu-systemd:24.04"
49+
- "ghcr.io/hifis-net/debian-systemd:10"
50+
- "ghcr.io/hifis-net/debian-systemd:11"
51+
- "ghcr.io/hifis-net/debian-systemd:12"
52+
53+
steps:
54+
- name: "Check out the codebase."
55+
uses: "actions/checkout@v4"
56+
with:
57+
path: "ansible_collections/hifis/toolkit"
58+
59+
- name: "Prepare the job environment."
60+
uses: "./ansible_collections/hifis/toolkit/.github/workflows/prepare-action"
61+
62+
# https://github.com/ansible/molecule/issues/3806
63+
- name: "Help molecule to find the dependencies"
64+
run: |
65+
mkdir -p /home/runner/.ansible
66+
ln -s /home/runner/work/ansible-collection-toolkit/ansible-collection-toolkit/ansible_collections/hifis/toolkit/roles \
67+
/home/runner/.ansible/roles
68+
69+
- name: "Run Molecule tests."
70+
run: "pipenv run molecule test -s gitlab_runner"
71+
env:
72+
MOLECULE_IMAGE: "${{ matrix.image }}"
73+
AUTHENTICATION_TOKEN: "${{ secrets.authentication_token }}"
74+
working-directory: "ansible_collections/hifis/toolkit"

.github/workflows/prepare-action/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ runs:
1717
uses: "actions/setup-python@v5"
1818
id: "setup-python"
1919
with:
20-
python-version: "3.10"
20+
python-version: "3.12"
2121
cache: "pipenv"
2222

2323
- name: "Install dependencies via pipenv."

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ reuse = "~=3.0.2"
1919
ansible = "~=9.5.1"
2020

2121
[requires]
22-
python_version = "3.10"
22+
python_version = "3.12"

Pipfile.lock

Lines changed: 3 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ This collection provides production-ready Ansible roles used for providing servi
1818
software engineers, but not exclusively. The following use cases are supported:
1919

2020
* DevOps platform:
21-
* [GitLab](https://github.com/hifis-net/ansible-role-gitlab) (*coming soon!*)
22-
* [GitLab-Runner](https://github.com/hifis-net/ansible-role-gitlab-runner) (*coming soon!*)
23-
* [Redis](https://github.com/hifis-net/ansible-role-redis) (*coming soon!*)
21+
* [GitLab](https://github.com/hifis-net/ansible-role-gitlab) (**coming soon!**)
22+
* deploy [**GitLab-Runner**](roles/gitlab_runner) with a focus, but not limited, on Openstack autoscaling
23+
* [Redis](https://github.com/hifis-net/ansible-role-redis) (**coming soon!**)
2424
* Help desk:
25-
* [**Zammad**](roles/zammad)
25+
* [**Zammad**](roles/zammad)
2626
* High Availability (HA) / Load Balancing:
27-
* [HAProxy](https://github.com/hifis-net/ansible-role-haproxy) (*coming soon!*)
28-
* [**Keepalived**](roles/keepalived)
27+
* [HAProxy](https://github.com/hifis-net/ansible-role-haproxy) (*coming soon!*)
28+
* [**Keepalived**](roles/keepalived)
2929
* OS-related:
30-
* [**unattended-upgrades**](roles/unattended_upgrades)
31-
* [netplan](https://github.com/hifis-net/ansible-role-gitlab-netplan) (*coming soon!*)
32-
* distribute authorized [**SSH keys**](role/ssh_keys) to users
30+
* [**unattended-upgrades**](roles/unattended_upgrades)
31+
* [netplan](https://github.com/hifis-net/ansible-role-gitlab-netplan) (*coming soon!*)
32+
* distribute authorized [**SSH keys**](role/ssh_keys) to users
3333

3434
## Minimum required Ansible-version
3535

molecule/gitlab_runner/converge.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden - Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
- name: "Converge"
8+
hosts: "all"
9+
tasks:
10+
- name: "Include gitlab_runner role"
11+
ansible.builtin.include_role:
12+
name: "hifis.toolkit.gitlab_runner"

molecule/gitlab_runner/molecule.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden - Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
dependency:
8+
name: "galaxy"
9+
options:
10+
requirements-file: "molecule/gitlab_runner/requirements.yml"
11+
driver:
12+
name: "podman"
13+
platforms:
14+
- name: "instancegitlabciopenstack1"
15+
image: "${MOLECULE_IMAGE:-ghcr.io/hifis-net/ubuntu-systemd:24.04}"
16+
pre_build_image: true
17+
override_command: false
18+
privileged: true # Required to run Docker in Podman
19+
systemd: true
20+
tty: true
21+
- name: "instancegitlabciopenstack2"
22+
image: "${MOLECULE_IMAGE:-ghcr.io/hifis-net/ubuntu-systemd:24.04}"
23+
pre_build_image: true
24+
override_command: false
25+
privileged: true # Required to run Docker in Podman
26+
systemd: true
27+
tty: true
28+
provisioner:
29+
name: "ansible"
30+
playbooks:
31+
prepare: "prepare.yml"
32+
converge: "converge.yml"
33+
inventory:
34+
hosts:
35+
all:
36+
vars:
37+
gitlab_runner_concurrent: 4
38+
host_vars:
39+
instancegitlabciopenstack1:
40+
gitlab_runner_version: "16.11.0"
41+
gitlab_runner_deb_file: "https://packages.gitlab.com/runner/gitlab-runner/packages/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}/gitlab-runner_{{ gitlab_runner_pkg_version }}_amd64.deb/download.deb"
42+
gitlab_runner_install_docker: true
43+
gitlab_runner_ssh_public_key: "test_key.pub"
44+
gitlab_runner_ssh_private_key: "test_key"
45+
gitlab_runner_sentry_dsn: "https://[email protected]/1"
46+
gitlab_runner_registry_mirrors:
47+
- "http://registry-mirror1.example"
48+
- "https://registry-mirror2.example"
49+
gitlab_runner_insecure_registries:
50+
- "registry-mirror1.example"
51+
gitlab_runner_enable_session_server: true
52+
gitlab_runner_list:
53+
- name: "test01"
54+
url: "https://gitlab.com"
55+
description: "Molecule test runner"
56+
authentication_token: "${AUTHENTICATION_TOKEN}"
57+
executor: "docker"
58+
environment: ["CI_CPUS=8", "DOCKER_TLS_CERTDIR=/certs"]
59+
docker_security_opts: ["seccomp=unconfined"]
60+
docker_volumes: ["/cache", "/certs/client"]
61+
docker_devices: ["/dev/kfd", "/dev/dri"]
62+
docker_cpus: 2
63+
docker_gpus: "all"
64+
docker_memory: "2g"
65+
docker_image: "python:3.8"
66+
docker_network_mtu: 1442
67+
tags: ["docker", "hifis"]
68+
locked: true
69+
limit: 10
70+
instancegitlabciopenstack2:
71+
gitlab_runner_version: "16.11.0"
72+
gitlab_runner_install_docker: false
73+
gitlab_runner_ssh_public_key: ""
74+
gitlab_runner_ssh_private_key: ""
75+
gitlab_runner_registry_mirror: "https://registry-mirror.example"
76+
gitlab_runner_listen_address: "127.0.0.1:9252"
77+
gitlab_runner_set_default_network_opts: true
78+
gitlab_runner_list:
79+
- name: "test01"
80+
url: "https://gitlab.com"
81+
description: "Molecule test runner"
82+
authentication_token: "${AUTHENTICATION_TOKEN}"
83+
executor: "docker+machine"
84+
environment: ["CI_CPUS=8", "DOCKER_TLS_CERTDIR=/certs"]
85+
docker_volumes: ["/cache", "/certs/client", "/opt/docker/daemon.json:/etc/docker/daemon.json:ro"]
86+
docker_image: "python:3.8"
87+
docker_shm_size: 2147483648
88+
docker_disable_cache: true
89+
tags: ["docker", "hifis"]
90+
locked: true
91+
limit: 10
92+
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"
114+
cache_type: "s3"
115+
cache_server_address: "https://cache.example"
116+
cache_access_key: "key"
117+
cache_secret_key: "secret"
118+
cache_bucket_name: "bucket"
119+
cache_bucket_location: "eu-west-1"
120+
cache_insecure: "false"
121+
verifier:
122+
name: "ansible"
123+
scenario:
124+
name: "gitlab_runner"
125+
test_sequence:
126+
- "destroy"
127+
- "dependency"
128+
- "syntax"
129+
- "create"
130+
- "prepare"
131+
- "check"
132+
- "converge"
133+
- "idempotence"
134+
- "check"
135+
- "side_effect"
136+
- "verify"
137+
- "destroy"

molecule/gitlab_runner/prepare.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
- name: "Prepare"
8+
hosts: "all"
9+
tasks:
10+
- name: "Install necessary packages"
11+
when: "ansible_os_family == 'Debian'"
12+
block:
13+
- name: "Install missing dependencies"
14+
ansible.builtin.apt:
15+
name:
16+
- "sudo" # for `become` privilege escalation
17+
- "iproute2" # for gathering network facts
18+
- "ca-certificates" # for Gitlab-Runner download
19+
- "gpg"
20+
- "python3-debian"
21+
state: "present"
22+
update_cache: true
23+
- name: "Set up iptables"
24+
when: "ansible_distribution == 'Debian'"
25+
block:
26+
- name: "Install missing dependencies"
27+
ansible.builtin.apt:
28+
name:
29+
- "iptables"
30+
state: "present"
31+
update_cache: true
32+
- name: "Use legacy iptables"
33+
community.general.alternatives:
34+
name: "iptables"
35+
path: "/usr/sbin/iptables-legacy"
36+
- name: "Use legacy ip6tables"
37+
community.general.alternatives:
38+
name: "ip6tables"
39+
path: "/usr/sbin/ip6tables-legacy"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden - Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
roles:
8+
- name: "geerlingguy.docker"

molecule/gitlab_runner/test_key

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-----BEGIN OPENSSH PRIVATE KEY-----
2+
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
3+
QyNTUxOQAAACAZxWIoT1CX3FFjc3+Em53Hy5ht8AbF8QHWQb25c3H2hQAAAJCiuPqvorj6
4+
rwAAAAtzc2gtZWQyNTUxOQAAACAZxWIoT1CX3FFjc3+Em53Hy5ht8AbF8QHWQb25c3H2hQ
5+
AAAEBQMNsWaiJGO+9HM245p+bcdI6mucBBHnD+880/zEOOERnFYihPUJfcUWNzf4SbncfL
6+
mG3wBsXxAdZBvblzcfaFAAAACXVzZXJAaG9zdAECAwQ=
7+
-----END OPENSSH PRIVATE KEY-----
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden - Rossendorf (HZDR)
3+
4+
SPDX-License-Identifier: Apache-2.0

molecule/gitlab_runner/test_key.pub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBnFYihPUJfcUWNzf4SbncfLmG3wBsXxAdZBvblzcfaF
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SPDX-FileCopyrightText: Helmholtz Centre for Environmental Research (UFZ)
2+
SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden - Rossendorf (HZDR)
3+
4+
SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)