Skip to content

Commit 0cd36e2

Browse files
committed
gitlab-runner: Update molecule tests to catch missing become directives
Signed-off-by: Norman Ziegner <[email protected]>
1 parent 5966a0e commit 0cd36e2

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

molecule/gitlab_runner/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
---
77
- name: "Converge"
88
hosts: "all"
9+
become: false
910
tasks:
1011
- name: "Include gitlab_runner role"
1112
ansible.builtin.include_role:

molecule/gitlab_runner/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ provisioner:
3636
hosts:
3737
all:
3838
vars:
39+
ansible_user: "ansible"
3940
gitlab_runner_concurrent: 4
4041
gitlab_runner_hide_sensitive_changes: false
4142
host_vars:

molecule/gitlab_runner/prepare.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
---
77
- name: "Prepare"
88
hosts: "all"
9+
become: true
910
tasks:
1011
- name: "Install necessary packages"
1112
when: "ansible_facts.os_family == 'Debian'"

molecule/gitlab_runner/verify.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
failed_when: "'0.16.2-gitlab.25' not in machine_version.stdout"
4242

4343
- name: "Identify installed fleeting plugins"
44+
become: true
4445
ansible.builtin.command: "gitlab-runner fleeting list"
4546
register: "fleeting_cmd"
4647
changed_when: false
@@ -64,6 +65,7 @@
6465
- "gitlab_runner_version is defined"
6566

6667
- name: "Assert that ignition.json file was created"
68+
become: true
6769
ansible.builtin.stat:
6870
path: "/etc/gitlab-runner/ignition.json"
6971
register: "ignition"
@@ -73,12 +75,14 @@
7375
when: "gitlab_runner_ssh_public_key | default('') | length == 0 or gitlab_runner_ssh_public_key | default('') | length == 0"
7476
block:
7577
- name: "Assert that SSH key pair was created"
78+
become: true
7679
ansible.builtin.stat:
7780
path: "/etc/gitlab-runner/gitlab_runner_key"
7881
register: "ssh_key"
7982
failed_when: "not ssh_key.stat.isreg or ssh_key.stat.mode != '0600'"
8083

8184
- name: "Read generated SSH public key"
85+
become: true
8286
ansible.builtin.command: "cat /etc/gitlab-runner/gitlab_runner_key.pub"
8387
register: "generated_pub_key"
8488
changed_when: false
@@ -95,6 +99,7 @@
9599
- "gitlab_runner_ssh_private_key | default('') | length > 0"
96100

97101
- name: "Read flatcar linux config"
102+
become: true
98103
ansible.builtin.command: "cat /etc/gitlab-runner/ignition.json"
99104
register: "flatcar_linux_config"
100105
changed_when: false
@@ -109,6 +114,7 @@
109114
gitlab_runner_authentication_token: "{{ lookup('env', 'AUTHENTICATION_TOKEN') }}"
110115

111116
- name: "Assert that the runner was registered successfully"
117+
become: true
112118
ansible.builtin.command: "gitlab-runner list"
113119
changed_when: false
114120
register: "runners"
@@ -117,6 +123,7 @@
117123
when: "gitlab_runner_authentication_token | length > 0"
118124

119125
- name: "Assert that the verify command is successful"
126+
become: true
120127
ansible.builtin.command: "gitlab-runner verify"
121128
changed_when: false
122129
register: "runners_verify"
@@ -131,6 +138,7 @@
131138
failed_when: '"# TYPE gitlab_runner_version_info" not in metrics.content'
132139

133140
- name: "Unregister GitLab-Runner"
141+
become: true
134142
ansible.builtin.command: "gitlab-runner unregister --all-runners"
135143
changed_when: false
136144
# Do not verify runner registration in forks

0 commit comments

Comments
 (0)