-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcheck-ostree.yaml
1326 lines (1203 loc) · 50.2 KB
/
check-ostree.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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
- hosts: ostree_guest
become: no
vars:
fdo_credential: "false"
embedded_container: "false"
sysroot_ro: "false"
total_counter: "0"
failed_counter: "0"
firewall_feature: "false"
ignition: "false"
test_custom_dirs_files: "false"
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']
# 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
# check tpm device
- name: check tpm device
stat:
path: /dev/tpm0
ignore_errors: yes
when: fdo_credential == "true"
- 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
- name: check rpm-ostree status
command: rpm-ostree status
ignore_errors: yes
# case: check rt kernel installed after upgrade
- name: check installed kernel
command: uname -r
register: result_kernel
- name: check rt kernel installed
block:
- assert:
that:
- "'rt' in result_kernel.stdout"
fail_msg: "rt kernel not installed, ostree upgrade might be failed"
success_msg: "rt kernel 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 }}"
when: "'rt' in result_kernel.stdout"
# first installed or upgraded
- name: determine which stage the checking is running on
shell: rpm-ostree status --json | jq '.deployments | length'
register: result_stage
- set_fact:
checking_stage: "{{ result_stage.stdout }}"
# case: check fdo onboarding status
# after fdo onboarding finished, /boot/device-credentials will be moved to /etc/device-credentials
- name: check if fdo onboarding completed successfully
block:
- name: wait until the file /etc/device-credentials is present before continuing
wait_for:
path: /etc/device-credentials
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: fdo_credential == "true"
# case: check ostree commit correctly updated
- name: get deployed ostree commit
shell: rpm-ostree status --json | jq -r '.deployments[0].checksum'
register: result_commit
- name: make a json result
set_fact:
deploy_commit: "{{ result_commit.stdout }}"
- name: check commit deployed and built
block:
- assert:
that:
- deploy_commit == ostree_commit
fail_msg: "deployed ostree commit is not commit built by osbuild-composer"
success_msg: "successful building and deployment"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check ostree ref
- name: check ostree ref
shell: rpm-ostree status --json | jq -r '.deployments[0].origin'
register: result_ref
- name: check ostree ref deployed
block:
- assert:
that:
- result_ref.stdout == ostree_ref
fail_msg: "deployed ostree ref failed"
success_msg: "ostree ref successful building and deployment"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case from bug: https://bugzilla.redhat.com/show_bug.cgi?id=1848453
- name: check ostree-remount status
command: systemctl is-active ostree-remount.service
register: result_remount
- name: ostree-remount should be started
block:
- assert:
that:
- result_remount.stdout == "active"
fail_msg: "ostree-remount is not started by default"
success_msg: "starting ostree-remount successful"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
- name: set mount point device name
command: findmnt -r -o SOURCE -n /sysroot
register: result_sysroot_source
- set_fact:
device_name: "{{ result_sysroot_source.stdout }}"
# case: check pv format
- name: check pv format
shell: pvs --reportformat json | jq .report[0].pv[0].pv_fmt -r
become: yes
register: result_pv_fmt
when: "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
- name: "pv format should be lvm2"
block:
- assert:
that:
- result_pv_fmt.stdout == "lvm2"
fail_msg: "pv format is not lvm2"
success_msg: "pv format is lvm2"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
# case: check pv size
- name: check pv size
shell: pvs --reportformat json | jq .report[0].pv[0].pv_size -r
become: yes
register: result_pv_size
when: "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
# simplified installer uses coreos-installer to grow fs to 19G
- name: "pv size should bigger than 19G"
block:
- assert:
that:
- "'19' in result_pv_size.stdout"
fail_msg: "pv size is not bigger than 19G"
success_msg: "pv size is bigger than 19G"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
- fdo_credential == "true"
- ansible_facts['distribution'] == 'RedHat'
# on fedora, it grows to 18.49G
- name: "pv size should bigger than 18G"
block:
- assert:
that:
- "'18' in result_pv_size.stdout"
fail_msg: "pv size is not bigger than 18G"
success_msg: "pv size is bigger than 18G"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
- fdo_credential == "true"
- ansible_facts['distribution'] == "Fedora"
# raw image does not have coreos-installer to grow fs to 19G
- name: "pv size should keep at 9G for raw image"
block:
- assert:
that:
- "'9' in result_pv_size.stdout"
fail_msg: "pv size does not keep at 9G"
success_msg: "pv size keeps at 9G"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
- fdo_credential == "false"
# case: check /sysroot lv size
- name: check sysroot lv size
shell: df -h | grep sysroot
register: result_sysroot_lv_size
when: "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
- name: "/sysroot lv size should be 9G"
block:
- assert:
that:
- "'9.0G' in result_sysroot_lv_size.stdout"
fail_msg: "pv size is not 9G"
success_msg: "pv size is 9G"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
- ansible_facts['distribution'] == 'RedHat'
# lv size on fedora is 7.8G, /~https://github.com/osbuild/osbuild-composer/issues/3529
- name: "/sysroot lv size should be 7.8G on fedora"
block:
- assert:
that:
- "'7.8G' in result_sysroot_lv_size.stdout"
fail_msg: "lv size is not 7.8G"
success_msg: "lv size is 7.8G"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
- ansible_facts['distribution'] == "Fedora"
# case: check /sysroot mount status
- name: check /sysroot mount status
shell: findmnt -r -o OPTIONS -n /sysroot | awk -F "," '{print $1}'
register: result_sysroot_mount_status
- name: /sysroot should be mount with rw permission
block:
- assert:
that:
- result_sysroot_mount_status.stdout == "rw"
fail_msg: "/sysroot is not mounted with rw permission"
success_msg: "/sysroot is mounted with rw permission"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: sysroot_ro == "false"
# https://fedoraproject.org/wiki/Changes/Silverblue_Kinoite_readonly_sysroot
- name: /sysroot should be mount with ro permission on RHEL 9.2 and Fedora 37 above
block:
- assert:
that:
- result_sysroot_mount_status.stdout == "ro"
fail_msg: "/sysroot is not mounted with ro permission"
success_msg: "/sysroot is mounted with ro permission"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: sysroot_ro == "true"
# case: check /var mount point
- name: check /var mount point
command: findmnt -r -o SOURCE -n /var
register: result_var_mount_point
- name: "/var should be mounted on {{ device_name }}[/ostree/deploy/{{ os_name }}/var]"
block:
- assert:
that:
- result_var_mount_point.stdout == "{{ device_name }}[/ostree/deploy/{{ os_name }}/var]"
fail_msg: "/var does not mount on {{ device_name }}[/ostree/deploy/{{ os_name }}/var]"
success_msg: "/var mounts on {{ device_name }}[/ostree/deploy/{{ os_name }}/var]"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check /var mount status
- name: check /var mount status
shell: findmnt -r -o OPTIONS -n /var | awk -F "," '{print $1}'
register: result_var_mount_status
- name: /var should be mount with rw permission
block:
- assert:
that:
- result_var_mount_status.stdout == "rw"
fail_msg: "/var is not mounted with rw permission"
success_msg: "/var is mounted with rw permission"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check /usr mount point
- name: check /usr mount point
command: findmnt -r -o SOURCE -n /usr
register: result_usr_mount_point
- name: "/usr should be mounted on {{ device_name }}[/ostree/deploy/{{ os_name }}/deploy/{{ deploy_commit }}.0/usr]"
block:
- assert:
that:
- result_usr_mount_point.stdout == "{{ device_name }}[/ostree/deploy/{{ os_name }}/deploy/{{ deploy_commit }}.0/usr]"
fail_msg: "/usr does not mount on {{ device_name }}[/ostree/deploy/{{ os_name }}/deploy/{{ deploy_commit }}.0/usr]"
success_msg: "/usr mounts on {{ device_name }}[/ostree/deploy/{{ os_name }}/deploy/{{ deploy_commit }}.0/usr]"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check /usr mount status
- name: check /usr mount status
shell: findmnt -r -o OPTIONS -n /usr | awk -F "," '{print $1}'
register: result_usr_mount_status
- name: /usr should be mount with rw permission
block:
- assert:
that:
- result_usr_mount_status.stdout == "ro"
fail_msg: "/usr is not mounted with ro permission"
success_msg: "/usr is mounted with ro permission"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
- name: get the first 10 chars in commit hash
set_fact:
commit_log: "{{ deploy_commit[:11] }}"
# Ignition test only
# Ignition test running by user core, otherwise by user admin
- name: check hello.service added by ignition
command: systemctl list-unit-files hello.service
register: result_hello_service
changed_when: no
ignore_errors: yes
when: ignition == "true"
- name: hello.service should be added by ignition
block:
- assert:
that:
- result_hello_service.rc == 0
fail_msg: "hello.service does not exist"
success_msg: "hello.service has been added by ignition"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: ignition == "true"
# Ignition test only
# Ignition test running by user core, otherwise by user admin
- name: check log_trace.conf for fdo-client-linuxapp.service updated by ignition
command: grep -Fxq "Environment=LOG_LEVEL=trace" /etc/systemd/system/fdo-client-linuxapp.service.d/log_trace.conf
register: result_log_trace
changed_when: no
become: yes
ignore_errors: yes
when: ignition == "true"
- name: Environment=LOG_LEVEL=trace should be added by ignition
block:
- assert:
that:
- result_log_trace.rc == 0
fail_msg: "Config Environment=LOG_LEVEL=trace does not exist"
success_msg: "Environment=LOG_LEVEL=trace has been added by ignition"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: ignition == "true"
# Ignition test only
# hello.service just run a shell script for echo "Hello, World!"
- name: check systemd service correctly started on firstboot
block:
- name: check hello.service logs
command: journalctl -b -0 -u hello.service
register: result_hello_service_log
become: yes
- assert:
that:
- "'Hello, World!' in result_hello_service_log.stdout"
fail_msg: "hello.service doesn't have the correct log"
success_msg: "hello.service started and working"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: ignition == "true"
# case: check wget installed after upgrade
- name: check installed package
shell: rpm -qa | sort
register: result_packages
- 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 }}"
when: checking_stage == "2"
# case: check dmesg error and failed log
- name: check dmesg output
command: dmesg
become: yes
# Ignore ignition first attempt error log, it'll be successful at the second attempt
# e.g. ignition[630]: GET error: Get "http://192.168.100.1/ignition/config.ign": dial tcp 192.168.100.1:80: connect: network is unreachable
# Workaround for bug https://issues.redhat.com/browse/RHEL-43587, ignore NetworkManager[614] NetworkManager[625]
- name: check dmesg error and fail log
shell: dmesg --notime | grep -i "error\|fail" | grep -v "skipped" | grep -v "failover" | grep -v "ignition" | grep -v "BAR 13":" failed to assign" | grep -v "failed to assign" | grep -v "NetworkManager" || true
register: result_dmesg_error
become: yes
- name: no more error or failed log
block:
- assert:
that:
# Work around for issue /~https://github.com/virt-s1/rhel-edge/issues/1402
- result_dmesg_error.stdout_lines | length <= 5
- "'pcieport 0000:00:01.6: Failed to check link status' in result_dmesg_error.stdout or 'Error: Driver \\'pcspkr\\' is already registered, aborting' in result_dmesg_error.stdout or 'KD_FONT_OP_GET failed while trying to get the font metadata: Invalid argument' in result_dmesg_error.stdout or 'sys-module-fuse.device: Failed to enqueue SYSTEMD_WANTS= job, ignoring: Unit sys-fs-fuse-connections.mount not found' in result_dmesg_error.stdout or '/usr/lib/systemd/system-generators/podman-system-generator failed with exit status 1' in result_dmesg_error.stdout or result_dmesg_error.stdout == ''"
fail_msg: "more or less error and failed log"
success_msg: "everything works as expected"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- ansible_facts['distribution'] == "RedHat" or ansible_facts['distribution'] == 'CentOS'
- "'rt' not in result_kernel.stdout"
- ansible_facts['architecture'] == "x86_64"
- name: no more error or failed log on aarch64
block:
- assert:
that:
# Fedora has 5 failed logs:
# NUMA: Failed to initialise from firmware
# 2 * systemd[1]: bpf-lsm: Failed to link program; assuming BPF LSM is not available
# systemd-gpt-auto-generator[581]: Failed to dissect: Permission denied
# systemd[572]: /usr/lib/systemd/system-generators/systemd-gpt-auto-generator failed with exit status 1.
- result_dmesg_error.stdout_lines | length <= 10
- "'NUMA: Failed to initialise from firmware' in result_dmesg_error.stdout or 'systemd[1]: bpf-lsm: Failed to link program; assuming BPF LSM is not available' in result_dmesg_error.stdout or result_dmesg_error.stdout == ''"
fail_msg: "more or less error and failed log"
success_msg: "everything works as expected"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- ansible_facts['architecture'] == "aarch64"
- name: no any error or fail log
block:
- assert:
that:
# Work around for issue /~https://github.com/virt-s1/rhel-edge/issues/1402
# Work around for issue /~https://github.com/virt-s1/rhel-edge/issues/1893
# Word around for issue /~https://github.com/virt-s1/rhel-edge/issues/1943
- result_dmesg_error.stdout_lines | length <= 5
fail_msg: "no any error fail log or only have one log"
success_msg: "everything works as expected"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- "'rt' in result_kernel.stdout"
- ansible_facts['architecture'] == "x86_64"
- name: no more error or failed log
block:
- assert:
that:
- result_dmesg_error.stdout_lines | length <= 5
# - "'pcieport 0000:00:01.6: pciehp: Failed to check link status' in result_dmesg_error.stdout"
- "'RAS: Correctable Errors collector initialized' in result_dmesg_error.stdout or 'systemd[1]: bpf-lsm: Failed to load BPF object: No such process' in result_dmesg_error.stdout or 'Failed to dissect: Permission denied' in result_dmesg_error.stdout or '/usr/lib/systemd/system-generators/systemd-gpt-auto-generator failed with exit status 1' in result_dmesg_error.stdout"
fail_msg: "more or less error and failed log"
success_msg: "everything works as expected"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- ansible_facts['distribution'] == "Fedora"
- "'rt' not in result_kernel.stdout"
- ansible_facts['architecture'] == "x86_64"
- name: check embedded container image with podman
command: podman images
become: yes
register: result_podman_images
when:
- embedded_container == "true"
- name: embedded container should be listed by podman images
block:
- assert:
that:
- "'quay.io/fedora/fedora' in result_podman_images.stdout"
fail_msg: "fedora image is not built in image"
success_msg: "fedora image is built in image"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- embedded_container == "true"
- name: embedded fedora-minimal container image should be listed by podman images
block:
- assert:
that:
- "'localhost/fedora-minimal' in result_podman_images.stdout"
fail_msg: "fedora-minimal image is not built in image"
success_msg: "fedora-minimal image is built in image"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- embedded_container == "true"
- ansible_architecture == "x86_64"
- (ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.2', '>='))
- name: embedded fedora-aarch64 container image should be listed by podman images
block:
- assert:
that:
- "'localhost/fedora-aarch64' in result_podman_images.stdout"
fail_msg: "fedora-aarch64 image is not built in image"
success_msg: "fedora-aarch64 image is built in image"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- embedded_container == "true"
- ansible_architecture == "aarch64"
- (ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.2', '>='))
- name: run ubi8 image with root
command: podman run ubi8-minimal:latest cat /etc/redhat-release
register: podman_result
become: yes
retries: 30
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)
# workaround on RHEL 8.6 and 9.0 for issue https://bugzilla.redhat.com/show_bug.cgi?id=2078937
# because the fix is not available on 8.6 and 9.0 yet
# bug https://bugzilla.redhat.com/show_bug.cgi?id=2123611 fix is not landed on CS8
- 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
# bug https://bugzilla.redhat.com/show_bug.cgi?id=2123611 fix is not landed on CS8
- 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 fedora-minimal container with podman
- name: run fedora-minimal image
command: podman run localhost/fedora-minimal@sha256:4d76a7480ce1861c95975945633dc9d03807ffb45c64b664ef22e673798d414b cat /etc/os-release
register: fminimal_container_result
become: yes
retries: 30 # due to /~https://github.com/osbuild/osbuild-composer/issues/2492
delay: 2
until: fminimal_container_result is success
ignore_errors: yes # due to https://bugzilla.redhat.com/show_bug.cgi?id=1903983
when:
- embedded_container == "true"
- ansible_architecture == "x86_64"
- (ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.2', '>='))
- name: run fedora-minimal container test
block:
- assert:
that:
- fminimal_container_result is succeeded
- "'Fedora Linux 36 (Container Image)' in fminimal_container_result.stdout"
- "'Trying to pull' not in fminimal_container_result.stdout"
fail_msg: "failed run fedora-minimal container with podman"
success_msg: "running fedora-minimal container with podman succeeded"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- embedded_container == "true"
- ansible_architecture == "x86_64"
- (ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.2', '>='))
# case: check fedora-aarch64 container with podman
- name: run fedora-aarch64 image
command: podman run localhost/fedora-aarch64@sha256:8fd6ac4c552bbec7910df7b0625310561d56513ecbcc418825a2f5635efecfab cat /etc/os-release
register: faarch64_container_result
become: yes
retries: 30 # due to /~https://github.com/osbuild/osbuild-composer/issues/2492
delay: 2
until: faarch64_container_result is success
ignore_errors: yes # due to https://bugzilla.redhat.com/show_bug.cgi?id=1903983
when:
- embedded_container == "true"
- ansible_architecture == "aarch64"
- (ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.2', '>='))
- name: run fedora-aarch64 container test
block:
- assert:
that:
- faarch64_container_result is succeeded
- "'Trying to pull' not in faarch64_container_result.stdout"
fail_msg: "failed run fedora-aarch64 container with podman"
success_msg: "running fedora-aarch64 container with podman succeeded"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- embedded_container == "true"
- ansible_architecture == "aarch64"
- (ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.2', '>='))
# case: check dnf package and it should not be installed
# /~https://github.com/osbuild/osbuild-composer/blob/master/internal/distro/rhel8/distro.go#L642
- name: dnf should not be installed
block:
- name: dnf should not be installed
shell: rpm -qa | grep dnf || echo -n PASS
register: result_dnf
- assert:
that:
- result_dnf.stdout == "PASS"
fail_msg: "dnf is installed"
success_msg: "No dnf installed"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.0', '<')
# case: check installed greenboot packages
- name: greenboot should be installed
block:
- name: greenboot should be installed
shell: rpm -qa | grep greenboot
register: result_greenboot_packages
- assert:
that:
- "'greenboot-0' in result_greenboot_packages.stdout"
- "'greenboot-default-health-checks' in result_greenboot_packages.stdout"
fail_msg: "greenboot is not installed"
success_msg: "greenboot is installed"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check greenboot* services
- name: a list of greenboot* service should be enabled
block:
- name: a list of greenboot* service should be enabled
command: systemctl is-enabled greenboot-grub2-set-counter greenboot-grub2-set-success greenboot-healthcheck greenboot-rpm-ostree-grub2-check-fallback greenboot-status greenboot-task-runner redboot-auto-reboot redboot-task-runner
register: result_greenboot_service
- assert:
that:
- result_greenboot_service.stdout == 'enabled\nenabled\nenabled\nenabled\nenabled\nenabled\nenabled\nenabled'
fail_msg: "Some of greenboot* services are not enabled"
success_msg: "All greenboot* services are enabled"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check greenboot* services log
- name: all greenboot* service should run without error
block:
# check service/target status instead of string matching messages
- name: check boot-complete.target
# will fail if the target was not reached
command: systemctl --no-pager status boot-complete.target
register: result
retries: 10
delay: 60
until: "'inactive' not in result.stdout"
- name: all greenboot* service should run without error
command: journalctl -b -0 -u greenboot -u greenboot-healthcheck -u greenboot-rpm-ostree-grub2-check-fallback -u greenboot-grub2-set-counter -u greenboot-grub2-set-success -u greenboot-status -u redboot -u redboot-auto-reboot -u redboot.target
become: yes
register: result_greenboot_log
- assert:
that:
- "'Script \\'00_required_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout"
- "'Script \\'00_wanted_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout"
- "'greenboot Health Checks Runner' in result_greenboot_log.stdout"
- "'Mark boot as successful in grubenv' in result_greenboot_log.stdout"
- "'Boot Status is GREEN - Health Check SUCCESS' in result_greenboot_log.stdout"
- "'greenboot MotD Generator' in result_greenboot_log.stdout"
fail_msg: "Some errors happened in service boot"
success_msg: "All greenboot services booted success"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check grubenv variables
- name: grubenv variables should contain boot_success=1
block:
- name: grubenv variables should contain boot_success=1
command: grub2-editenv list
register: result_grubenv
become: yes
- assert:
that:
- "'boot_success=1' in result_grubenv.stdout"
fail_msg: "Not found boot_success=1"
success_msg: "Found boot_success=1"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# Check FDO status and task status
- name: check fdo-client-linuxapp logs
command: journalctl -u fdo-client-linuxapp
register: result_fdo_client_linuxapp_journalctl
become: yes
when:
- fdo_credential == "true"
# Check FDO client avc log
- name: check FDO client avc logs
command: ausearch -m avc -m user_avc -m selinux_err -i
ignore_errors: yes
become: yes
when:
- fdo_credential == "true"
# case: check rollback function if boot error found
- name: install sanely failing health check unit to test red boot status behavior
block:
- name: install sanely failing health check unit to test red boot status behavior
command: rpm-ostree install --cache-only https://kite-webhook-prod.s3.amazonaws.com/greenboot-failing-unit-1.0-1.el8.noarch.rpm --reboot
become: yes
ignore_errors: yes
ignore_unreachable: yes
- name: delay 60 seconds before reboot to make system stable
pause:
seconds: 60
delegate_to: 127.0.0.1
- 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
- assert:
that:
- result_rollback is succeeded
fail_msg: "Rollback failed"
success_msg: "Rollback success"
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
register: result_list_boots
become: yes
- 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 }}"