|
| 1 | +--- |
| 2 | +- hosts: image_mode_guest |
| 3 | + become: no |
| 4 | + vars: |
| 5 | + fdo_credential: "false" |
| 6 | + total_counter: "0" |
| 7 | + failed_counter: "0" |
| 8 | + |
| 9 | + tasks: |
| 10 | + # check installed fido device onboard packages |
| 11 | + - name: fdo should be installed |
| 12 | + block: |
| 13 | + - name: fdo should be installed |
| 14 | + shell: rpm -qa | grep -E 'fdo|fido' |
| 15 | + |
| 16 | + # check tpm device |
| 17 | + - name: check tpm device |
| 18 | + stat: |
| 19 | + path: /dev/tpm0 |
| 20 | + ignore_errors: yes |
| 21 | + when: fdo_credential == "true" |
| 22 | + |
| 23 | + # case: check fdo onboarding status |
| 24 | + # after fdo onboarding finished, /boot/device-credentials will be moved to /etc/device-credentials |
| 25 | + - name: check if fdo onboarding completed successfully |
| 26 | + block: |
| 27 | + - name: wait until the file /etc/device-credentials is present before continuing |
| 28 | + wait_for: |
| 29 | + path: /etc/device-credentials |
| 30 | + always: |
| 31 | + - set_fact: |
| 32 | + total_counter: "{{ total_counter | int + 1 }}" |
| 33 | + rescue: |
| 34 | + - name: failed count + 1 |
| 35 | + set_fact: |
| 36 | + failed_counter: "{{ failed_counter | int + 1 }}" |
| 37 | + when: fdo_credential == "true" |
| 38 | + |
| 39 | + # Check FDO status and task status |
| 40 | + - name: check fdo-client-linuxapp logs |
| 41 | + command: journalctl -u fdo-client-linuxapp |
| 42 | + register: result_fdo_client_linuxapp_journalctl |
| 43 | + become: yes |
| 44 | + when: |
| 45 | + - fdo_credential == "true" |
| 46 | + |
| 47 | + - name: check secure device onboarding successful |
| 48 | + block: |
| 49 | + - assert: |
| 50 | + that: |
| 51 | + - "'Secure Device Onboarding DONE' in result_fdo_client_linuxapp_journalctl.stdout" |
| 52 | + fail_msg: "Secure Device Onboarding not successful" |
| 53 | + success_msg: "Secure Device Onboarding successful" |
| 54 | + always: |
| 55 | + - set_fact: |
| 56 | + total_counter: "{{ total_counter | int + 1 }}" |
| 57 | + rescue: |
| 58 | + - name: failed count + 1 |
| 59 | + set_fact: |
| 60 | + failed_counter: "{{ failed_counter | int + 1 }}" |
| 61 | + when: fdo_credential == "true" |
| 62 | + |
| 63 | + # Check FDO client avc log |
| 64 | + - name: check FDO client avc logs |
| 65 | + command: ausearch -m avc -m user_avc -m selinux_err -i |
| 66 | + ignore_errors: yes |
| 67 | + become: yes |
| 68 | + when: |
| 69 | + - fdo_credential == "true" |
| 70 | + |
| 71 | + - assert: |
| 72 | + that: |
| 73 | + - failed_counter == "0" |
| 74 | + fail_msg: "Run {{ total_counter }} tests, but {{ failed_counter }} of them failed" |
| 75 | + success_msg: "Totally {{ total_counter }} test passed" |
0 commit comments