Skip to content

Commit 1d5f232

Browse files
committed
Fix ansible-lint violations in gitlab_runner role
1 parent 5e50654 commit 1d5f232

File tree

14 files changed

+158
-159
lines changed

14 files changed

+158
-159
lines changed

.github/workflows/gitlab_runner.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ env:
3434
jobs:
3535

3636
test:
37-
name: Run Molecule tests.
38-
runs-on: ubuntu-24.04
37+
name: "Run Molecule tests."
38+
runs-on: "ubuntu-24.04"
3939
env:
4040
PY_COLORS: 1
4141
ANSIBLE_FORCE_COLOR: 1
@@ -70,5 +70,5 @@ jobs:
7070
run: "pipenv run molecule test -s gitlab_runner"
7171
env:
7272
MOLECULE_IMAGE: "${{ matrix.image }}"
73-
AUTHENTICATION_TOKEN: ${{ secrets.authentication_token }}
73+
AUTHENTICATION_TOKEN: "${{ secrets.authentication_token }}"
7474
working-directory: "ansible_collections/hifis/toolkit"

molecule/gitlab_runner/converge.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
---
7-
- name: Converge
8-
hosts: all
7+
- name: "Converge"
8+
hosts: "all"
99
tasks:
1010
- name: "Include gitlab_runner role"
1111
ansible.builtin.include_role:

molecule/gitlab_runner/molecule.yml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55

66
---
77
dependency:
8-
name: galaxy
8+
name: "galaxy"
99
options:
1010
requirements-file: "molecule/gitlab_runner/requirements.yml"
1111
driver:
12-
name: podman
12+
name: "podman"
1313
platforms:
14-
- name: instancegitlabciopenstack1
15-
image: ${MOLECULE_IMAGE:-ghcr.io/hifis-net/ubuntu-systemd:24.04}
14+
- name: "instancegitlabciopenstack1"
15+
image: "${MOLECULE_IMAGE:-ghcr.io/hifis-net/ubuntu-systemd:24.04}"
1616
pre_build_image: true
1717
override_command: false
1818
privileged: true # Required to run Docker in Podman
1919
systemd: true
2020
tty: true
21-
- name: instancegitlabciopenstack2
22-
image: ${MOLECULE_IMAGE:-ghcr.io/hifis-net/ubuntu-systemd:24.04}
21+
- name: "instancegitlabciopenstack2"
22+
image: "${MOLECULE_IMAGE:-ghcr.io/hifis-net/ubuntu-systemd:24.04}"
2323
pre_build_image: true
2424
override_command: false
2525
privileged: true # Required to run Docker in Podman
2626
systemd: true
2727
tty: true
2828
provisioner:
29-
name: ansible
29+
name: "ansible"
3030
playbooks:
31-
prepare: prepare.yml
32-
converge: converge.yml
31+
prepare: "prepare.yml"
32+
converge: "converge.yml"
3333
inventory:
3434
hosts:
3535
all:
@@ -53,7 +53,7 @@ provisioner:
5353
- name: "test01"
5454
url: "https://gitlab.com"
5555
description: "Molecule test runner"
56-
authentication_token: ${AUTHENTICATION_TOKEN}
56+
authentication_token: "${AUTHENTICATION_TOKEN}"
5757
executor: "docker"
5858
environment: ["CI_CPUS=8", "DOCKER_TLS_CERTDIR=/certs"]
5959
docker_security_opts: ["seccomp=unconfined"]
@@ -65,7 +65,7 @@ provisioner:
6565
docker_image: "python:3.8"
6666
docker_network_mtu: 1442
6767
tags: ["docker", "hifis"]
68-
locked: True
68+
locked: true
6969
limit: 10
7070
instancegitlabciopenstack2:
7171
gitlab_runner_version: "16.11.0"
@@ -79,15 +79,15 @@ provisioner:
7979
- name: "test01"
8080
url: "https://gitlab.com"
8181
description: "Molecule test runner"
82-
authentication_token: ${AUTHENTICATION_TOKEN}
82+
authentication_token: "${AUTHENTICATION_TOKEN}"
8383
executor: "docker+machine"
8484
environment: ["CI_CPUS=8", "DOCKER_TLS_CERTDIR=/certs"]
8585
docker_volumes: ["/cache", "/certs/client", "/opt/docker/daemon.json:/etc/docker/daemon.json:ro"]
8686
docker_image: "python:3.8"
8787
docker_shm_size: 2147483648
88-
docker_disable_cache: True
88+
docker_disable_cache: true
8989
tags: ["docker", "hifis"]
90-
locked: True
90+
locked: true
9191
limit: 10
9292
machine_idle_count: 5
9393
machine_idle_time: 7200
@@ -119,19 +119,19 @@ provisioner:
119119
cache_bucket_location: "eu-west-1"
120120
cache_insecure: "false"
121121
verifier:
122-
name: ansible
122+
name: "ansible"
123123
scenario:
124-
name: gitlab_runner
124+
name: "gitlab_runner"
125125
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
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: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
---
7-
- name: Prepare
8-
hosts: all
7+
- name: "Prepare"
8+
hosts: "all"
99
tasks:
10-
- name: Install necessary packages
11-
when: ansible_os_family == 'Debian'
10+
- name: "Install necessary packages"
11+
when: "ansible_os_family == 'Debian'"
1212
block:
13-
- name: Install missing dependencies
13+
- name: "Install missing dependencies"
1414
ansible.builtin.apt:
1515
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: yes
23-
- name: Set up iptables
24-
when: ansible_distribution == 'Debian'
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'"
2525
block:
2626
- name: "Install missing dependencies"
2727
ansible.builtin.apt:
2828
name:
2929
- "iptables"
3030
state: "present"
31-
update_cache: yes
31+
update_cache: true
3232
- name: "Use legacy iptables"
3333
community.general.alternatives:
3434
name: "iptables"

molecule/gitlab_runner/requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
---
77
roles:
8-
- name: geerlingguy.docker
8+
- name: "geerlingguy.docker"

molecule/gitlab_runner/verify.yml

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,123 +4,123 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
---
7-
- name: Verify
8-
hosts: all
7+
- name: "Verify"
8+
hosts: "all"
99
tasks:
10-
- name: Gather package facts
10+
- name: "Gather package facts"
1111
ansible.builtin.package_facts:
12-
manager: auto
12+
manager: "auto"
1313

14-
- name: Gather service facts
14+
- name: "Gather service facts"
1515
ansible.builtin.service_facts:
1616

17-
- name: Assert that docker is installed
18-
when: gitlab_runner_install_docker
17+
- name: "Assert that docker is installed"
18+
when: "gitlab_runner_install_docker"
1919
ansible.builtin.assert:
2020
that:
2121
- "'docker-ce' in ansible_facts.packages"
2222

23-
- name: Assert that docker is not installed
24-
when: not gitlab_runner_install_docker
23+
- name: "Assert that docker is not installed"
24+
when: "not gitlab_runner_install_docker"
2525
ansible.builtin.assert:
2626
that:
2727
- "'docker-ce' not in ansible_facts.packages"
2828

29-
- name: Assert that Docker systemd service is running
30-
when: gitlab_runner_install_docker
29+
- name: "Assert that Docker systemd service is running"
30+
when: "gitlab_runner_install_docker"
3131
ansible.builtin.assert:
3232
that:
3333
- "ansible_facts.services['docker.service'].state == 'running'"
3434
- "ansible_facts.services['docker.service'].status == 'enabled'"
3535

36-
- name: Check that docker-machine is properly installed
37-
ansible.builtin.command: docker-machine version
36+
- name: "Check that docker-machine is properly installed"
37+
ansible.builtin.command: "docker-machine version"
3838
changed_when: false
39-
register: machine_version
39+
register: "machine_version"
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: Assert that Gitlab-Runner is installed
43+
- name: "Assert that Gitlab-Runner is installed"
4444
ansible.builtin.assert:
4545
that:
4646
- "'gitlab-runner' in ansible_facts.packages"
4747

48-
- name: Assert that installed GitLab Runner version is equal to the desired one
48+
- name: "Assert that installed GitLab Runner version is equal to the desired one"
4949
ansible.builtin.assert:
5050
that:
5151
- "ansible_facts.packages['gitlab-runner'][0].version == gitlab_runner_version + '-1'"
5252
when:
53-
- gitlab_runner_version is defined
53+
- "gitlab_runner_version is defined"
5454

55-
- name: Assert that ignition.json file was created
55+
- name: "Assert that ignition.json file was created"
5656
ansible.builtin.stat:
57-
path: /etc/gitlab-runner/ignition.json
58-
register: ignition
59-
failed_when: not ignition.stat.isreg
57+
path: "/etc/gitlab-runner/ignition.json"
58+
register: "ignition"
59+
failed_when: "not ignition.stat.isreg"
6060

61-
- name: Determine generated SSH public key
62-
when: gitlab_runner_ssh_public_key | default("") | length == 0 or gitlab_runner_ssh_public_key | default("") | length == 0
61+
- name: "Determine generated SSH public key"
62+
when: "gitlab_runner_ssh_public_key | default('') | length == 0 or gitlab_runner_ssh_public_key | default('') | length == 0"
6363
block:
64-
- name: Assert that SSH key pair was created
64+
- name: "Assert that SSH key pair was created"
6565
ansible.builtin.stat:
66-
path: /etc/gitlab-runner/gitlab_runner_key
67-
register: ssh_key
68-
failed_when: not ssh_key.stat.isreg or ssh_key.stat.mode != "0600"
66+
path: "/etc/gitlab-runner/gitlab_runner_key"
67+
register: "ssh_key"
68+
failed_when: "not ssh_key.stat.isreg or ssh_key.stat.mode != '0600'"
6969

70-
- name: Read generated SSH public key
71-
ansible.builtin.command: cat /etc/gitlab-runner/gitlab_runner_key.pub
72-
register: generated_pub_key
70+
- name: "Read generated SSH public key"
71+
ansible.builtin.command: "cat /etc/gitlab-runner/gitlab_runner_key.pub"
72+
register: "generated_pub_key"
7373
changed_when: false
7474

75-
- name: Store generated SSH public key in variable
75+
- name: "Store generated SSH public key in variable"
7676
ansible.builtin.set_fact:
7777
gitlab_runner_ssh_key: "{{ generated_pub_key.stdout | trim }}"
7878

79-
- name: Store predefined SSH public key in variable
79+
- name: "Store predefined SSH public key in variable"
8080
ansible.builtin.set_fact:
8181
gitlab_runner_ssh_key: "{{ lookup('file', gitlab_runner_ssh_public_key) | trim }}"
8282
when:
83-
- gitlab_runner_ssh_public_key | default("") | length > 0
84-
- gitlab_runner_ssh_private_key | default("") | length > 0
83+
- "gitlab_runner_ssh_public_key | default('') | length > 0"
84+
- "gitlab_runner_ssh_private_key | default('') | length > 0"
8585

86-
- name: Read flatcar linux config
87-
ansible.builtin.command: cat /etc/gitlab-runner/ignition.json
88-
register: flatcar_linux_config
86+
- name: "Read flatcar linux config"
87+
ansible.builtin.command: "cat /etc/gitlab-runner/ignition.json"
88+
register: "flatcar_linux_config"
8989
changed_when: false
9090

91-
- name: Assert that SSH public key exists in flatcar linux config
91+
- name: "Assert that SSH public key exists in flatcar linux config"
9292
ansible.builtin.assert:
9393
that:
94-
- flatcar_linux_config.stdout.find(gitlab_runner_ssh_key) != -1
94+
- "flatcar_linux_config.stdout.find(gitlab_runner_ssh_key) != -1"
9595

96-
- name: Store authentication token environment variable as Ansible fact.
96+
- name: "Store authentication token environment variable as Ansible fact."
9797
ansible.builtin.set_fact:
9898
gitlab_runner_authentication_token: "{{ lookup('env', 'AUTHENTICATION_TOKEN') }}"
9999

100-
- name: Assert that the runner was registered successfully
101-
ansible.builtin.command: gitlab-runner list
100+
- name: "Assert that the runner was registered successfully"
101+
ansible.builtin.command: "gitlab-runner list"
102102
changed_when: false
103-
register: runners
103+
register: "runners"
104104
failed_when: "'test01' not in runners.stderr"
105105
# Do not verify runner registration in forks
106106
when: "gitlab_runner_authentication_token | length > 0"
107107

108-
- name: Assert that the verify command is successful
109-
ansible.builtin.command: gitlab-runner verify
108+
- name: "Assert that the verify command is successful"
109+
ansible.builtin.command: "gitlab-runner verify"
110110
changed_when: false
111-
register: runners_verify
112-
failed_when: runners_verify.rc != 0
111+
register: "runners_verify"
112+
failed_when: "runners_verify.rc != 0"
113113

114114
- name: "Assert that metrics endpoint is activated"
115115
when: "gitlab_runner_listen_address is defined and gitlab_runner_listen_address | length > 0"
116116
ansible.builtin.uri:
117117
url: "http://{{ gitlab_runner_listen_address }}/metrics"
118-
return_content: yes
118+
return_content: true
119119
register: "metrics"
120120
failed_when: '"# TYPE gitlab_runner_version_info" not in metrics.content'
121121

122-
- name: Unregister GitLab-Runner
123-
ansible.builtin.command: gitlab-runner unregister --all-runners
122+
- name: "Unregister GitLab-Runner"
123+
ansible.builtin.command: "gitlab-runner unregister --all-runners"
124124
changed_when: false
125125
# Do not verify runner registration in forks
126126
when: "gitlab_runner_authentication_token | length > 0"

requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ collections:
1111
- name: "community.general"
1212

1313
roles:
14-
- name: geerlingguy.docker
14+
- name: "geerlingguy.docker"

roles/gitlab_runner/defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ gitlab_runner_transpiler_binary_checksum: "sha256:28003c61b991d17d66c23cd3f30520
2121
gitlab_runner_install_docker: true
2222

2323
gitlab_runner_namerservers:
24-
- 9.9.9.9
25-
- 149.112.112.112
24+
- "9.9.9.9"
25+
- "149.112.112.112"
2626

2727
gitlab_runner_mtu: 1450
2828

0 commit comments

Comments
 (0)