forked from virt-s1/rhel-edge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-minimal.yaml
311 lines (277 loc) · 11.5 KB
/
check-minimal.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
---
- hosts: ostree_guest
become: no
vars:
total_counter: "0"
failed_counter: "0"
download_node: ""
tasks:
# current target host's IP address
- debug: var=ansible_all_ipv4_addresses
- debug: var=ansible_facts['distribution_version']
- debug: var=ansible_facts['distribution']
- debug: var=ansible_facts['architecture']
# Expand disk for Fedora 39+
- name: expand disk
when: (ansible_facts['distribution'] == 'Fedora') and (ansible_facts ['distribution_version'] is version('38', '>')) and (ansible_facts['architecture'] == "aarch64")
block:
- name: expand partition
command: growpart /dev/vda 3
ignore_errors: yes
- name: expand filesystem
command: resize2fs /dev/vda3
ignore_errors: yes
# check BIOS or UEFI
- name: check bios or uefi
stat:
path: /sys/firmware/efi
# check secure boot status if it's enabled
- name: check secure boot status
command: mokutil --sb-state
ignore_errors: yes
- name: check partition size
command: df -h
ignore_errors: yes
become: yes
- name: check disk partition table
command: fdisk -l
ignore_errors: yes
become: yes
# case: check rt kernel installed after upgrade
- name: check installed kernel
command: uname -r
# case: check wget installed after upgrade
- name: check installed package
shell: rpm -qa | sort
register: result_packages
# case: check package installed in blueprint
- name: check wget installed
block:
- assert:
that:
- "'wget' in result_packages.stdout"
fail_msg: "wget not installed, ostree upgrade might be failed"
success_msg: "wget installed in ostree upgrade"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
- name: enable persistent logging for the systemd journal
file:
path: /var/log/journal
state: directory
become: yes
when: ansible_facts['distribution'] == 'RedHat' or ansible_facts['distribution'] == 'CentOS' or (ansible_facts['architecture'] == "aarch64" and ansible_facts['distribution_version'] == "39")
- name: enable persistent logging on RHEL 9, CS9 and Fedora 39 for ARM
command: journalctl --flush
become: yes
when: ansible_facts['distribution_version'] == "9.4" or ansible_facts['distribution_version'] == "9.3" or ansible_facts['distribution_version'] == "9" or (ansible_facts['architecture'] == "aarch64" and ansible_facts['distribution_version'] == "39")
- name: add RHEL 9.5 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.5.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.5', '==')
- name: add RHEL 9.5 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.5.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.5', '==')
- name: add RHEL 9.4 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.4.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.4', '==')
- name: add RHEL 9.4 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.4.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.4', '==')
- name: add RHEL 9.3 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/updates/RHEL-9/latest-RHEL-9.3.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.3', '==')
- name: add RHEL 9.3 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/updates/RHEL-9/latest-RHEL-9.3.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.3', '==')
- name: add RHEL 8.10 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-8/nightly/RHEL-8/latest-RHEL-8.10.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('8.10', '==')
- name: add RHEL 8.10 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-8/nightly/RHEL-8/latest-RHEL-8.10.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('8.10', '==')
- name: add RHEL 8.9 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-8/nightly/updates/RHEL-8/latest-RHEL-8.9.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('8.9', '==')
- name: add RHEL 8.9 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-8/nightly/updates/RHEL-8/latest-RHEL-8.9.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('8.9', '==')
- name: install podman
dnf:
name:
- podman
state: latest
become: yes
# case: check dmesg error and failed log
- name: check dmesg output
command: dmesg
register: result_dmesg
- name: check dmesg error and fail log
shell: dmesg --notime | grep -i "error\|fail" | grep -v "skipped" | grep -v "failover" || true
register: result_dmesg_error
# case: check running container with podman
- name: run ubi8 image with root
command: podman run ubi8-minimal:latest cat /etc/redhat-release
register: podman_result
become: yes
retries: 30 # due to https://github.com/osbuild/osbuild-composer/issues/2492
delay: 2
until: podman_result is success
ignore_errors: yes
- name: run container test
block:
- assert:
that:
- podman_result is succeeded
- "'Red Hat Enterprise Linux release' in podman_result.stdout"
fail_msg: "failed run container with podman (root)"
success_msg: "running container with podman (root) succeeded"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check running container with podman (non-root)
- name: run ubi8 image with non-root
command: podman run ubi8:latest cat /etc/redhat-release
register: podman_result
retries: 30 # due to https://github.com/osbuild/osbuild-composer/issues/2492
delay: 2
until: podman_result is success
ignore_errors: yes
- name: run container test
block:
- assert:
that:
- podman_result is succeeded
- "'Red Hat Enterprise Linux release' in podman_result.stdout"
fail_msg: "failed run container with podman (non-root)"
success_msg: "running container with podman (non-root) succeeded"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check rebooting
- name: check rebooting
block:
- name: reboot to deploy new ostree commit
reboot:
post_reboot_delay: 10
pre_reboot_delay: 5
become: yes
- name: wait for connection to become reachable/usable
wait_for_connection:
delay: 30
- name: waits until instance is reachable
wait_for:
host: "{{ ansible_all_ipv4_addresses[0] }}"
port: 22
search_regex: OpenSSH
delay: 10
register: result_rollback
until: result_rollback is success
retries: 6
delay: 10
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check persistent log in Edge system
- name: check journald has persistent logging
block:
- name: list boots
shell: journalctl --list-boots -q
register: result_list_boots
- assert:
that:
- result_list_boots.stdout_lines | length > 1
fail_msg: "journald hasn't persistent logging"
success_msg: "journald has persistent logging"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
# Disable rhel9.5 check due to bug https://issues.redhat.com/projects/RHEL/issues/RHEL-45151
- (ansible_facts['distribution'] == 'RedHat' and ansible_facts['distribution_version'] is version('9.5', '!=')) or
(ansible_facts['distribution'] == 'CentOS') or
(ansible_facts['distribution'] == 'Fedora')
- assert:
that:
- failed_counter == "0"
fail_msg: "Run {{ total_counter }} tests, but {{ failed_counter }} of them failed"
success_msg: "Totally {{ total_counter }} test passed"