|
| 1 | +--- |
| 2 | +- hosts: ostree_guest |
| 3 | + become: no |
| 4 | + vars: |
| 5 | + total_counter: "0" |
| 6 | + failed_counter: "0" |
| 7 | + |
| 8 | + tasks: |
| 9 | + |
| 10 | + # current target host's IP address |
| 11 | + - debug: var=ansible_all_ipv4_addresses |
| 12 | + - debug: var=ansible_facts['distribution_version'] |
| 13 | + - debug: var=ansible_facts['distribution'] |
| 14 | + - debug: var=ansible_facts['architecture'] |
| 15 | + |
| 16 | + # check BIOS or UEFI |
| 17 | + - name: check bios or uefi |
| 18 | + stat: |
| 19 | + path: /sys/firmware/efi |
| 20 | + |
| 21 | + # check secure boot status if it's enabled |
| 22 | + - name: check secure boot status |
| 23 | + command: mokutil --sb-state |
| 24 | + ignore_errors: yes |
| 25 | + |
| 26 | + # check tpm device |
| 27 | + - name: check tpm device |
| 28 | + stat: |
| 29 | + path: /dev/tpm0 |
| 30 | + ignore_errors: yes |
| 31 | + |
| 32 | + - name: check partition size |
| 33 | + command: df -h |
| 34 | + ignore_errors: yes |
| 35 | + become: yes |
| 36 | + |
| 37 | + - name: check disk partition table |
| 38 | + command: fdisk -l |
| 39 | + ignore_errors: yes |
| 40 | + become: yes |
| 41 | + |
| 42 | + - name: check rpm-ostree status |
| 43 | + command: rpm-ostree status |
| 44 | + ignore_errors: yes |
| 45 | + |
| 46 | + - name: check installed kernel |
| 47 | + command: uname -r |
| 48 | + |
| 49 | + # first installed or upgraded |
| 50 | + - name: determine which stage the checking is running on |
| 51 | + shell: rpm-ostree status --json | jq '.deployments | length' |
| 52 | + register: result_stage |
| 53 | + |
| 54 | + - set_fact: |
| 55 | + checking_stage: "{{ result_stage.stdout }}" |
| 56 | + |
| 57 | + # case: check fdo onboarding status |
| 58 | + # after fdo onboarding finished, /boot/device-credentials will be moved to /etc/device-credentials |
| 59 | + - name: check if fdo onboarding completed successfully |
| 60 | + block: |
| 61 | + - name: wait until the file /etc/device-credentials is present before continuing |
| 62 | + wait_for: |
| 63 | + path: /etc/device-credentials |
| 64 | + always: |
| 65 | + - set_fact: |
| 66 | + total_counter: "{{ total_counter | int + 1 }}" |
| 67 | + rescue: |
| 68 | + - name: failed count + 1 |
| 69 | + set_fact: |
| 70 | + failed_counter: "{{ failed_counter | int + 1 }}" |
| 71 | + |
| 72 | + # case: check ostree commit correctly updated |
| 73 | + - name: get deployed ostree commit |
| 74 | + shell: rpm-ostree status --json | jq -r '.deployments[0].checksum' |
| 75 | + register: result_commit |
| 76 | + |
| 77 | + - name: make a json result |
| 78 | + set_fact: |
| 79 | + deploy_commit: "{{ result_commit.stdout }}" |
| 80 | + |
| 81 | + - name: check commit deployed and built |
| 82 | + block: |
| 83 | + - assert: |
| 84 | + that: |
| 85 | + - deploy_commit == ostree_commit |
| 86 | + fail_msg: "deployed ostree commit is not commit built by osbuild-composer" |
| 87 | + success_msg: "successful building and deployment" |
| 88 | + always: |
| 89 | + - set_fact: |
| 90 | + total_counter: "{{ total_counter | int + 1 }}" |
| 91 | + rescue: |
| 92 | + - name: failed count + 1 |
| 93 | + set_fact: |
| 94 | + failed_counter: "{{ failed_counter | int + 1 }}" |
| 95 | + |
| 96 | + # case: check ostree ref |
| 97 | + - name: check ostree ref |
| 98 | + shell: rpm-ostree status --json | jq -r '.deployments[0].origin' |
| 99 | + register: result_ref |
| 100 | + |
| 101 | + - name: check ostree ref deployed |
| 102 | + block: |
| 103 | + - assert: |
| 104 | + that: |
| 105 | + - result_ref.stdout == ostree_ref |
| 106 | + fail_msg: "deployed ostree ref failed" |
| 107 | + success_msg: "ostree ref successful building and deployment" |
| 108 | + always: |
| 109 | + - set_fact: |
| 110 | + total_counter: "{{ total_counter | int + 1 }}" |
| 111 | + rescue: |
| 112 | + - name: failed count + 1 |
| 113 | + set_fact: |
| 114 | + failed_counter: "{{ failed_counter | int + 1 }}" |
| 115 | + |
| 116 | + # case: check wget installed after upgrade |
| 117 | + - name: check installed package |
| 118 | + shell: rpm -qa | sort |
| 119 | + register: result_packages |
| 120 | + |
| 121 | + - name: check wget installed |
| 122 | + block: |
| 123 | + - assert: |
| 124 | + that: |
| 125 | + - "'wget' in result_packages.stdout" |
| 126 | + fail_msg: "wget not installed, ostree upgrade might be failed" |
| 127 | + success_msg: "wget installed in ostree upgrade" |
| 128 | + always: |
| 129 | + - set_fact: |
| 130 | + total_counter: "{{ total_counter | int + 1 }}" |
| 131 | + rescue: |
| 132 | + - name: failed count + 1 |
| 133 | + set_fact: |
| 134 | + failed_counter: "{{ failed_counter | int + 1 }}" |
| 135 | + when: checking_stage == "2" |
| 136 | + |
| 137 | + - name: check dmesg output |
| 138 | + command: dmesg |
| 139 | + |
| 140 | + # Check FDO status and task status |
| 141 | + - name: check fdo-client-linuxapp logs |
| 142 | + command: journalctl -u fdo-client-linuxapp |
| 143 | + become: yes |
| 144 | + |
| 145 | + # Check re-encryption status on x86_64 |
| 146 | + - name: wait for FDO re-encryption |
| 147 | + block: |
| 148 | + - shell: cryptsetup luksDump /dev/vda4 |
| 149 | + register: result |
| 150 | + until: not result.stdout_lines is search("cipher_null-ecb") |
| 151 | + retries: 30 |
| 152 | + delay: 60 |
| 153 | + always: |
| 154 | + - set_fact: |
| 155 | + total_counter: "{{ total_counter | int + 1 }}" |
| 156 | + rescue: |
| 157 | + - name: failed count + 1 |
| 158 | + set_fact: |
| 159 | + failed_counter: "{{ failed_counter | int + 1 }}" |
| 160 | + |
| 161 | + # Check FDO status and task status |
| 162 | + - name: check fdo-client-linuxapp logs |
| 163 | + command: journalctl -u fdo-client-linuxapp |
| 164 | + become: yes |
| 165 | + |
| 166 | + - assert: |
| 167 | + that: |
| 168 | + - failed_counter == "0" |
| 169 | + fail_msg: "Run {{ total_counter }} tests, but {{ failed_counter }} of them failed" |
| 170 | + success_msg: "Totally {{ total_counter }} test passed" |
0 commit comments