|
4 | 4 | # SPDX-License-Identifier: Apache-2.0 |
5 | 5 |
|
6 | 6 | --- |
7 | | -- name: Verify |
8 | | - hosts: all |
| 7 | +- name: "Verify" |
| 8 | + hosts: "all" |
9 | 9 | tasks: |
10 | | - - name: Gather package facts |
| 10 | + - name: "Gather package facts" |
11 | 11 | ansible.builtin.package_facts: |
12 | | - manager: auto |
| 12 | + manager: "auto" |
13 | 13 |
|
14 | | - - name: Gather service facts |
| 14 | + - name: "Gather service facts" |
15 | 15 | ansible.builtin.service_facts: |
16 | 16 |
|
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" |
19 | 19 | ansible.builtin.assert: |
20 | 20 | that: |
21 | 21 | - "'docker-ce' in ansible_facts.packages" |
22 | 22 |
|
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" |
25 | 25 | ansible.builtin.assert: |
26 | 26 | that: |
27 | 27 | - "'docker-ce' not in ansible_facts.packages" |
28 | 28 |
|
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" |
31 | 31 | ansible.builtin.assert: |
32 | 32 | that: |
33 | 33 | - "ansible_facts.services['docker.service'].state == 'running'" |
34 | 34 | - "ansible_facts.services['docker.service'].status == 'enabled'" |
35 | 35 |
|
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" |
38 | 38 | changed_when: false |
39 | | - register: machine_version |
| 39 | + register: "machine_version" |
40 | 40 | when: "gitlab_runner_list | selectattr('executor', 'equalto', 'docker+machine') | list | length > 0" |
41 | 41 | failed_when: "'0.16.2-gitlab.25' not in machine_version.stdout" |
42 | 42 |
|
43 | | - - name: Assert that Gitlab-Runner is installed |
| 43 | + - name: "Assert that Gitlab-Runner is installed" |
44 | 44 | ansible.builtin.assert: |
45 | 45 | that: |
46 | 46 | - "'gitlab-runner' in ansible_facts.packages" |
47 | 47 |
|
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" |
49 | 49 | ansible.builtin.assert: |
50 | 50 | that: |
51 | 51 | - "ansible_facts.packages['gitlab-runner'][0].version == gitlab_runner_version + '-1'" |
52 | 52 | when: |
53 | | - - gitlab_runner_version is defined |
| 53 | + - "gitlab_runner_version is defined" |
54 | 54 |
|
55 | | - - name: Assert that ignition.json file was created |
| 55 | + - name: "Assert that ignition.json file was created" |
56 | 56 | 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" |
60 | 60 |
|
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" |
63 | 63 | block: |
64 | | - - name: Assert that SSH key pair was created |
| 64 | + - name: "Assert that SSH key pair was created" |
65 | 65 | 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'" |
69 | 69 |
|
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" |
73 | 73 | changed_when: false |
74 | 74 |
|
75 | | - - name: Store generated SSH public key in variable |
| 75 | + - name: "Store generated SSH public key in variable" |
76 | 76 | ansible.builtin.set_fact: |
77 | 77 | gitlab_runner_ssh_key: "{{ generated_pub_key.stdout | trim }}" |
78 | 78 |
|
79 | | - - name: Store predefined SSH public key in variable |
| 79 | + - name: "Store predefined SSH public key in variable" |
80 | 80 | ansible.builtin.set_fact: |
81 | 81 | gitlab_runner_ssh_key: "{{ lookup('file', gitlab_runner_ssh_public_key) | trim }}" |
82 | 82 | 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" |
85 | 85 |
|
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" |
89 | 89 | changed_when: false |
90 | 90 |
|
91 | | - - name: Assert that SSH public key exists in flatcar linux config |
| 91 | + - name: "Assert that SSH public key exists in flatcar linux config" |
92 | 92 | ansible.builtin.assert: |
93 | 93 | that: |
94 | | - - flatcar_linux_config.stdout.find(gitlab_runner_ssh_key) != -1 |
| 94 | + - "flatcar_linux_config.stdout.find(gitlab_runner_ssh_key) != -1" |
95 | 95 |
|
96 | | - - name: Store authentication token environment variable as Ansible fact. |
| 96 | + - name: "Store authentication token environment variable as Ansible fact." |
97 | 97 | ansible.builtin.set_fact: |
98 | 98 | gitlab_runner_authentication_token: "{{ lookup('env', 'AUTHENTICATION_TOKEN') }}" |
99 | 99 |
|
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" |
102 | 102 | changed_when: false |
103 | | - register: runners |
| 103 | + register: "runners" |
104 | 104 | failed_when: "'test01' not in runners.stderr" |
105 | 105 | # Do not verify runner registration in forks |
106 | 106 | when: "gitlab_runner_authentication_token | length > 0" |
107 | 107 |
|
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" |
110 | 110 | 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" |
113 | 113 |
|
114 | 114 | - name: "Assert that metrics endpoint is activated" |
115 | 115 | when: "gitlab_runner_listen_address is defined and gitlab_runner_listen_address | length > 0" |
116 | 116 | ansible.builtin.uri: |
117 | 117 | url: "http://{{ gitlab_runner_listen_address }}/metrics" |
118 | | - return_content: yes |
| 118 | + return_content: true |
119 | 119 | register: "metrics" |
120 | 120 | failed_when: '"# TYPE gitlab_runner_version_info" not in metrics.content' |
121 | 121 |
|
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" |
124 | 124 | changed_when: false |
125 | 125 | # Do not verify runner registration in forks |
126 | 126 | when: "gitlab_runner_authentication_token | length > 0" |
0 commit comments