|
12 | 12 | - debug: var=ansible_facts['distribution'] |
13 | 13 | - debug: var=ansible_facts['architecture'] |
14 | 14 |
|
15 | | - # case: check installed greenboot packages |
16 | | - - name: greenboot should be installed |
| 15 | + # case: check greenboot* services |
| 16 | + - name: greenboot healthcheck service should be enabled |
17 | 17 | block: |
18 | | - - name: greenboot should be installed |
19 | | - shell: rpm -qa | grep greenboot |
20 | | - register: result_greenboot_packages |
| 18 | + - name: greenboot healthcheck service should be enabled |
| 19 | + command: systemctl is-enabled greenboot-healthcheck |
| 20 | + register: result_greenboot_service |
21 | 21 |
|
22 | 22 | - assert: |
23 | 23 | that: |
24 | | - - "'greenboot-0' in result_greenboot_packages.stdout" |
25 | | - - "'greenboot-default-health-checks' in result_greenboot_packages.stdout" |
26 | | - fail_msg: "greenboot is not installed" |
27 | | - success_msg: "greenboot is installed" |
| 24 | + - result_greenboot_service.stdout == 'enabled' |
| 25 | + fail_msg: "at least one greenboot service is not enabled" |
| 26 | + success_msg: "greenboot services are enabled" |
28 | 27 | always: |
29 | 28 | - set_fact: |
30 | 29 | total_counter: "{{ total_counter | int + 1 }}" |
|
33 | 32 | set_fact: |
34 | 33 | failed_counter: "{{ failed_counter | int + 1 }}" |
35 | 34 |
|
36 | | - # case: check greenboot* services |
37 | | - - name: a list of greenboot* service should be enabled |
| 35 | + # case: check greenboot* service status |
| 36 | + - name: greenboot healthcheck service should be active |
38 | 37 | block: |
39 | | - - name: a list of greenboot* service should be enabled |
40 | | - 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 |
41 | | - register: result_greenboot_service |
| 38 | + - name: greenboot healthcheck service should be active |
| 39 | + command: systemctl is-active greenboot-healthcheck.service |
| 40 | + register: result_greenboot_active |
42 | 41 |
|
43 | 42 | - assert: |
44 | 43 | that: |
45 | | - - result_greenboot_service.stdout == 'enabled\nenabled\nenabled\nenabled\nenabled\nenabled\nenabled\nenabled' |
46 | | - fail_msg: "at least one greenboot service is not enabled" |
47 | | - success_msg: "greenboot services are enabled" |
| 44 | + - result_greenboot_active.stdout == "active" |
| 45 | + fail_msg: "greenboot healthcheck service is not active" |
| 46 | + success_msg: "greenboot healthcheck service is active" |
48 | 47 | always: |
49 | 48 | - set_fact: |
50 | 49 | total_counter: "{{ total_counter | int + 1 }}" |
|
53 | 52 | set_fact: |
54 | 53 | failed_counter: "{{ failed_counter | int + 1 }}" |
55 | 54 |
|
56 | | - # case: check greenboot* services log |
57 | | - - name: all greenboot* service should run without error |
| 55 | + # case: check boot-complete.target status |
| 56 | + - name: boot-complete.target should be active |
58 | 57 | block: |
59 | | - # check service/target status instead of string matching messages |
60 | 58 | - name: check boot-complete.target |
61 | | - # will fail if the target was not reached |
62 | 59 | command: systemctl --no-pager status boot-complete.target |
| 60 | + become: yes |
63 | 61 | register: result |
64 | 62 | retries: 10 |
65 | 63 | delay: 60 |
66 | 64 | until: "'inactive' not in result.stdout" |
67 | 65 |
|
68 | | - - name: all greenboot* service should run without error |
69 | | - 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 |
70 | | - become: yes |
71 | | - register: result_greenboot_log |
72 | | - |
73 | | - - assert: |
74 | | - that: |
75 | | - - "'Script \\'00_required_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout" |
76 | | - - "'Script \\'00_wanted_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout" |
77 | | - - "'greenboot Health Checks Runner' in result_greenboot_log.stdout" |
78 | | - - "'Mark boot as successful in grubenv' in result_greenboot_log.stdout" |
79 | | - - "'Boot Status is GREEN - Health Check SUCCESS' in result_greenboot_log.stdout" |
80 | | - - "'greenboot MotD Generator' in result_greenboot_log.stdout" |
81 | | - fail_msg: "Some errors happened in service boot" |
82 | | - success_msg: "All greenboot services booted success" |
83 | | - |
84 | | - always: |
85 | | - - set_fact: |
86 | | - total_counter: "{{ total_counter | int + 1 }}" |
87 | | - rescue: |
88 | | - - name: failed count + 1 |
89 | | - set_fact: |
90 | | - failed_counter: "{{ failed_counter | int + 1 }}" |
91 | | - |
92 | | - # case: check grubenv variables |
93 | | - - name: grubenv variables should contain boot_success=1 |
94 | | - block: |
95 | | - - name: grubenv variables should contain boot_success=1 |
96 | | - command: grub2-editenv list |
97 | | - register: result_grubenv |
98 | | - become: yes |
99 | | - |
100 | | - - assert: |
101 | | - that: |
102 | | - - "'boot_success=1' in result_grubenv.stdout" |
103 | | - fail_msg: "Not found boot_success=1" |
104 | | - success_msg: "Found boot_success=1" |
105 | 66 | always: |
106 | 67 | - set_fact: |
107 | 68 | total_counter: "{{ total_counter | int + 1 }}" |
|
156 | 117 | set_fact: |
157 | 118 | failed_counter: "{{ failed_counter | int + 1 }}" |
158 | 119 |
|
159 | | - # case: check greenboot* services log again |
| 120 | + # case: check fallback log |
160 | 121 | - name: fallback log should be found here |
161 | 122 | block: |
162 | | - # check service/target status instead of string matching messages |
163 | | - - name: check boot-complete.target |
164 | | - # will fail if the target was not reached |
165 | | - command: systemctl --no-pager status boot-complete.target |
166 | | - become: yes |
167 | | - register: result |
168 | | - retries: 10 |
169 | | - delay: 60 |
170 | | - until: "'inactive' not in result.stdout" |
171 | | - |
172 | 123 | - name: fallback log should be found here |
173 | | - 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 |
| 124 | + command: journalctl -b -0 -u greenboot -u greenboot-healthcheck |
174 | 125 | become: yes |
175 | 126 | register: result_greenboot_log |
176 | 127 |
|
177 | 128 | - assert: |
178 | 129 | that: |
179 | | - - "'FALLBACK BOOT DETECTED! Default rpm-ostree deployment has been rolled back' in result_greenboot_log.stdout" |
180 | | - - "'Script \\'00_required_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout" |
181 | | - - "'Script \\'00_wanted_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout" |
182 | | - - "'greenboot Health Checks Runner' in result_greenboot_log.stdout" |
183 | | - - "'Mark boot as successful in grubenv' in result_greenboot_log.stdout" |
184 | | - - "'Boot Status is GREEN - Health Check SUCCESS' in result_greenboot_log.stdout" |
185 | | - - "'greenboot MotD Generator' in result_greenboot_log.stdout" |
| 130 | + - "'FALLBACK BOOT DETECTED!' in result_greenboot_log.stdout" |
186 | 131 | fail_msg: "Fallback log not found" |
187 | 132 | success_msg: "Found fallback log" |
188 | 133 |
|
|
0 commit comments