|
| 1 | +--- |
| 2 | +- name: Check if ownership already taken on IO nodes |
| 3 | + shell: | |
| 4 | + tpm2_getcap properties-variable | awk -F': *' '/ownerAuthSet:/ { v=tolower($2); print (v ~ /(^1$|set|true)/) ? 1 : 0; exit }' |
| 5 | + register: ownership_taken_io |
| 6 | + changed_when: false |
| 7 | + when: inventory_hostname in hostvars[groups['emsvm'][0]]['scale_io_nodes_list'] |
| 8 | + |
| 9 | +- name: Check if ownership already taken on utility node |
| 10 | + shell: | |
| 11 | + tpm2_getcap properties-variable | awk -F': *' '/ownerAuthSet:/ { v=tolower($2); print (v ~ /(^1$|set|true)/) ? 1 : 0; exit }' |
| 12 | + register: ownership_taken_utility |
| 13 | + changed_when: false |
| 14 | + when: inventory_hostname in hostvars[groups['emsvm'][0]]['scale_utility_nodes_list'] |
| 15 | + |
| 16 | +# skip the setup -> if ownership taken. We mention that ownership is taken, validate it. And continue to nv slot creation. |
| 17 | +- block: |
| 18 | + - name: Validate ownership password |
| 19 | + debug: |
| 20 | + msg: Ownership already taken. Skipping the tpm ownership setup. |
| 21 | + |
| 22 | + - name: Check the password |
| 23 | + command: mmvdisk tpm chpasswd --old-password-file {{ tpm_password_file }} --new-password-file {{ tpm_password_file }} |
| 24 | + register: pwd_validation_io |
| 25 | + |
| 26 | + - debug: |
| 27 | + msg: "Validated the Ownership successfully" |
| 28 | + when: pwd_validation_io.rc == 0 |
| 29 | + |
| 30 | + - fail: |
| 31 | + msg: "Ownership password did not match. Please verify" |
| 32 | + when: pw_validation_io.rc != 0 |
| 33 | + when: inventory_hostname in hostvars[groups['emsvm'][0]]['scale_io_nodes_list'] and ownership_taken_io.stdout == '1' and not change_password |
| 34 | + |
| 35 | +- block: |
| 36 | + - name: Validate ownership password |
| 37 | + debug: |
| 38 | + msg: Ownership already taken. Skipping the tpm ownership setup. |
| 39 | + |
| 40 | + - name: Check the password |
| 41 | + command: /opt/ibm/ess/tools/bin/.TPM/./esstpm chpasswd --old-password-file {{ tpm_password_file }} --new-password-file {{ tpm_password_file }} |
| 42 | + register: pwd_validation_utility |
| 43 | + |
| 44 | + - debug: |
| 45 | + msg: "Validated the Ownership successfully" |
| 46 | + when: pwd_validation_utility.rc == 0 |
| 47 | + |
| 48 | + - fail: |
| 49 | + msg: "Ownership password did not match. Please verify" |
| 50 | + when: pw_validation_utility.rc != 0 |
| 51 | + when: inventory_hostname in hostvars[groups['emsvm'][0]]['scale_utility_nodes_list'] and ownership_taken_utility.stdout == '1' and not change_password |
| 52 | + |
| 53 | +# if tpm ownership not taken already, proceed to take it on io nodes |
| 54 | +- block: |
| 55 | + - name: Disable TPM clear |
| 56 | + command: tpm2_clearcontrol -C l s |
| 57 | + register: disable_operation |
| 58 | + when: disable_clear |
| 59 | + |
| 60 | + - name: Take TPM ownership # ensure file permission is 600 |
| 61 | + command: mmvdisk tpm setup --password-file {{ tpm_password_file }} |
| 62 | + register: take_ownership_io |
| 63 | + |
| 64 | + - debug: |
| 65 | + msg: "{{(take_ownership.rc == 0) | ternary(take_ownership_io.stdout.split('\n'),take_ownership_io.stderr.split('\n')) }}" |
| 66 | + when: inventory_hostname in hostvars[groups['emsvm'][0]]['scale_io_nodes_list'] and ownership_taken_io.stdout == '0' and not change_password |
| 67 | + |
| 68 | +# if tpm ownership not taken already, proceed to take it on utility node |
| 69 | +- block: |
| 70 | + - name: Disable TPM clear |
| 71 | + command: tpm2_clearcontrol -C l s |
| 72 | + register: disable_operation |
| 73 | + when: disable_clear |
| 74 | + |
| 75 | + - name: Take TPM ownership on utility node |
| 76 | + command: /opt/ibm/ess/tools/bin/.TPM/./esstpm setup --password-file {{ tpm_password_file }} |
| 77 | + register: take_ownership_utility |
| 78 | + |
| 79 | + - debug: |
| 80 | + msg: "{{(take_ownership_utility.rc == 0) | ternary(take_ownership_utility.stdout.split('\n'), take_ownership_utility.stderr.split('\n')) }}" |
| 81 | + when: inventory_hostname in hostvars[groups['emsvm'][0]]['scale_utility_nodes_list'] and ownership_taken_utility.stdout == '0' and not change_password |
| 82 | + |
| 83 | +# execute only when change password is set to true. |
| 84 | +- block: |
| 85 | + - name: Change TPM Ownership password |
| 86 | + command: mmvdisk tpm chpasswd --old-password-file {{ tpm_password_file }} --new-password-file {{ new_tpm_password_file }} |
| 87 | + when: inventory_hostname in hostvars[groups['emsvm'][0]]['scale_io_nodes_list'] |
| 88 | + |
| 89 | + - name: Change TPM Ownership password on utility node |
| 90 | + command: /opt/ibm/ess/tools/bin/.TPM/./esstpm chpasswd --old-password-file {{ tpm_password_file }} --new-password-file {{ new_tpm_password_file }} |
| 91 | + when: inventory_hostname in hostvars[groups['emsvm'][0]]['scale_utility_nodes_list'] |
| 92 | + when: change_password |
| 93 | + |
| 94 | + |
| 95 | + |
0 commit comments