|
75 | 75 | ansible.builtin.assert: |
76 | 76 | that: |
77 | 77 | - >- |
78 | | - '/dev/mapper/encrypted-disk' in |
| 78 | + '/dev/mapper/encrypted_disk' in |
79 | 79 | (__test_findmnt.stdout | trim) |
80 | 80 | fail_msg: >- |
81 | | - Expected /dev/mapper/encrypted-disk to be mounted at |
| 81 | + Expected /dev/mapper/encrypted_disk to be mounted at |
82 | 82 | {{ trustee_client_encrypt_disk_mount_point }} but found: |
83 | 83 | {{ __test_findmnt.stdout }} |
84 | 84 | when: not __test_skip_encrypt_assertions |
85 | 85 |
|
86 | 86 | - name: Stat the LUKS mapper device |
87 | 87 | ansible.builtin.stat: |
88 | | - path: /dev/mapper/encrypted-disk |
| 88 | + path: /dev/mapper/encrypted_disk |
89 | 89 | register: __test_mapper_dev |
90 | 90 | when: not __test_skip_encrypt_assertions |
91 | 91 |
|
92 | 92 | - name: Assert LUKS mapper device exists |
93 | 93 | ansible.builtin.assert: |
94 | 94 | that: |
95 | 95 | - __test_mapper_dev.stat.exists |
96 | | - fail_msg: "LUKS mapper device /dev/mapper/encrypted-disk does not exist" |
| 96 | + fail_msg: "LUKS mapper device /dev/mapper/encrypted_disk does not exist" |
97 | 97 | when: not __test_skip_encrypt_assertions |
98 | 98 |
|
99 | 99 | - name: Assert encrypted_disk_key fact was set |
|
137 | 137 | /etc/containers/storage.conf does not reference the encrypted |
138 | 138 | disk mount point {{ trustee_client_encrypt_disk_mount_point }} |
139 | 139 | when: not __test_skip_encrypt_assertions |
| 140 | + |
| 141 | +- name: Ensure disk encryption works with systemd-cryptenroll when secret_registration_client is disabled |
| 142 | + hosts: all |
| 143 | + gather_facts: false |
| 144 | + vars: |
| 145 | + trustee_client_trustee_gc: false |
| 146 | + trustee_client_encrypt_disk: true |
| 147 | + trustee_client_secret_registration_enabled: false |
| 148 | + trustee_client_encrypt_disk_mount_point: /mnt/encrypted-disk |
| 149 | + tasks: |
| 150 | + - name: Check for an unpartitioned disk device |
| 151 | + ansible.builtin.shell: | |
| 152 | + set -o pipefail |
| 153 | + lsblk -n -o NAME,TYPE,PKNAME | awk ' |
| 154 | + $2=="disk" && $1 !~ /^zram|^loop|^dm/ { disk=$1; haspart[disk]=0 } |
| 155 | + $2=="part" { parent=$3; if (parent in haspart) haspart[parent]=1 } |
| 156 | + END { |
| 157 | + for (d in haspart) { |
| 158 | + if (haspart[d] == 0) { |
| 159 | + print d |
| 160 | + exit 0 |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | + ' |
| 165 | + register: __test_unpartitioned_disk |
| 166 | + changed_when: false |
| 167 | + failed_when: false |
| 168 | + |
| 169 | + - name: Set fact when no unpartitioned disk is available |
| 170 | + ansible.builtin.set_fact: |
| 171 | + __test_skip_cryptenroll_assertions: "{{ __test_unpartitioned_disk.stdout | trim == '' }}" |
| 172 | + |
| 173 | + - name: Check systemd-cryptenroll exists |
| 174 | + ansible.builtin.command: type systemd-cryptenroll |
| 175 | + register: __test_cryptenroll_check |
| 176 | + changed_when: false |
| 177 | + failed_when: false |
| 178 | + when: not __test_skip_cryptenroll_assertions |
| 179 | + |
| 180 | + - name: Set fact when systemd-cryptenroll is not available |
| 181 | + ansible.builtin.set_fact: |
| 182 | + __test_skip_cryptenroll_assertions: "{{ __test_skip_cryptenroll_assertions or __test_cryptenroll_check.rc != 0 }}" |
| 183 | + when: not __test_skip_cryptenroll_assertions |
| 184 | + |
| 185 | + - name: Run trustee_client role with disk encryption (cryptenroll path) |
| 186 | + ansible.builtin.include_role: |
| 187 | + name: linux-system-roles.trustee_client |
| 188 | + when: not __test_skip_cryptenroll_assertions |
| 189 | + |
| 190 | + - name: Stat the encrypted disk mount point |
| 191 | + ansible.builtin.stat: |
| 192 | + path: "{{ trustee_client_encrypt_disk_mount_point }}" |
| 193 | + register: __test_mount_point |
| 194 | + when: not __test_skip_cryptenroll_assertions |
| 195 | + |
| 196 | + - name: Assert mount point directory exists |
| 197 | + ansible.builtin.assert: |
| 198 | + that: |
| 199 | + - __test_mount_point.stat.exists |
| 200 | + - __test_mount_point.stat.isdir |
| 201 | + fail_msg: >- |
| 202 | + Encrypted disk mount point |
| 203 | + {{ trustee_client_encrypt_disk_mount_point }} does not exist |
| 204 | + when: not __test_skip_cryptenroll_assertions |
| 205 | + |
| 206 | + - name: Assert the encrypted disk is mounted |
| 207 | + ansible.builtin.command: findmnt --noheadings --output SOURCE {{ trustee_client_encrypt_disk_mount_point }} |
| 208 | + register: __test_findmnt |
| 209 | + changed_when: false |
| 210 | + when: not __test_skip_cryptenroll_assertions |
| 211 | + |
| 212 | + - name: Assert the mounted device is the LUKS mapper device |
| 213 | + ansible.builtin.assert: |
| 214 | + that: |
| 215 | + - __test_findmnt.rc == 0 |
| 216 | + - "'/dev/mapper/encrypted_disk' in (__test_findmnt.stdout | default('') | trim)" |
| 217 | + fail_msg: >- |
| 218 | + Expected /dev/mapper/encrypted_disk to be mounted at |
| 219 | + {{ trustee_client_encrypt_disk_mount_point }} but found: |
| 220 | + {{ __test_findmnt.stdout | default('') }} |
| 221 | + when: not __test_skip_cryptenroll_assertions |
| 222 | + |
| 223 | + - name: Assert crypttab contains encrypted_disk entry |
| 224 | + ansible.builtin.slurp: |
| 225 | + src: /etc/crypttab |
| 226 | + register: __test_crypttab |
| 227 | + when: not __test_skip_cryptenroll_assertions |
| 228 | + |
| 229 | + - name: Verify crypttab has encrypted_disk with tpm2-device=auto |
| 230 | + ansible.builtin.assert: |
| 231 | + that: |
| 232 | + - "'encrypted_disk' in (__test_crypttab.content | b64decode)" |
| 233 | + - "'tpm2-device=auto' in (__test_crypttab.content | b64decode)" |
| 234 | + fail_msg: "/etc/crypttab does not contain encrypted_disk entry with tpm2-device=auto" |
| 235 | + when: not __test_skip_cryptenroll_assertions |
| 236 | + |
| 237 | + - name: Assert fstab contains encrypted disk mount |
| 238 | + ansible.builtin.slurp: |
| 239 | + src: /etc/fstab |
| 240 | + register: __test_fstab |
| 241 | + when: not __test_skip_cryptenroll_assertions |
| 242 | + |
| 243 | + - name: Verify fstab has encrypted disk mount point |
| 244 | + ansible.builtin.assert: |
| 245 | + that: |
| 246 | + - trustee_client_encrypt_disk_mount_point in (__test_fstab.content | b64decode) |
| 247 | + - "'/dev/mapper/encrypted_disk' in (__test_fstab.content | b64decode)" |
| 248 | + fail_msg: "/etc/fstab does not contain encrypted disk mount entry" |
| 249 | + when: not __test_skip_cryptenroll_assertions |
0 commit comments