File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed
infrastructure/server-setup Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 99### Improvements
1010
1111- Make encryption step optional [ #1123 ] ( https://github.com/opencrvs/opencrvs-countryconfig/pull/1123 )
12+ - Added validation for ENCRYPTION_KEY [ #10896 ] ( https://github.com/opencrvs/opencrvs-core/issues/10896 )
1213
1314## 1.9.0
1415
Original file line number Diff line number Diff line change 114114 tags :
115115 - data-partition
116116
117+ - include_tasks :
118+ file : tasks/validate-data-partition.yml
119+ apply :
120+ tags :
121+ - data-partition
122+ - decrypt-on-boot
123+ tags :
124+ - data-partition
125+ - decrypt-on-boot
126+
117127 - include_tasks :
118128 file : tasks/swap.yml
119129 apply :
Original file line number Diff line number Diff line change 1+
2+ - name : ' Register encrypted file system'
3+ stat :
4+ path : /cryptfs_file_sparse.img
5+ get_checksum : False
6+ register : encryptedFileSystemPostCheck
7+ when : disk_encryption_key is defined
8+
9+ - name : Check if Disk encryption key file exists
10+ ansible.builtin.stat :
11+ path : " /root/disk-encryption-key.txt"
12+ register : encryption_keyfile_stat
13+ when : disk_encryption_key is defined
14+
15+ - name : Read existing Disk encryption key
16+ ansible.builtin.slurp :
17+ src : " /root/disk-encryption-key.txt"
18+ register : existing_disk_encryption_key
19+ when :
20+ - disk_encryption_key is defined
21+ - encryption_keyfile_stat.stat.exists
22+
23+ - name : Fail if key exists and differs
24+ ansible.builtin.fail :
25+ msg : " Disk encryption key on disk does not match ansible variable! GitHub secret ENCRYPTION_KEY was updated!"
26+ when :
27+ - encryption_keyfile_stat.stat.exists
28+ - existing_disk_encryption_key['content'] | b64decode != ("DISK_ENCRYPTION_KEY=" ~ disk_encryption_key ~ "\n")
29+
130- name : Save disk encryption key into a file as an example (in production use a hardware security module)
231 when : disk_encryption_key is defined
332 ansible.builtin.copy :
Original file line number Diff line number Diff line change 1+ - name : Verify LUKS disk encryption key
2+ when : disk_encryption_key is defined
3+ block :
4+ - name : Backup LUKS header
5+ shell : |
6+ loop_device=$(losetup -j /cryptfs_file_sparse.img | cut -d: -f1)
7+ rm -vf /tmp/luks-header.img
8+ cryptsetup luksHeaderBackup $loop_device --header-backup-file /tmp/luks-header.img
9+
10+ - name : Test disk encryption key for LUKS header
11+ when : disk_encryption_key is defined
12+ shell : ' echo "{{ disk_encryption_key }}" | cryptsetup -d - luksOpen /tmp/luks-header.img test --test-passphrase'
13+ register : luks_test
14+
15+ - name : Display success message
16+ debug :
17+ msg : " ✓ LUKS passphrase test successful - the disk encryption key is valid: {{ luks_test.stdout }}"
18+ rescue :
19+ - name : DO NOT REBOOT the SERVER
20+ fail :
21+ msg : |
22+ {% if luks_test.rc == 2 and 'No key available with this passphrase' in luks_test.stderr -%}
23+ LUKS passphrase test failed: Please make sure your key in GitHub secret is correct. Otherwise system will not be able to decrypt /data. MAKE SURE DATA BACKUP IS RESTORABLE BEFORE SERVER REBOOT.
24+ {%- else -%}
25+ cryptsetup error (RC: {{ luks_test.rc }}) - {{ luks_test.stderr | default('Unknown error') }}
26+ {%- endif %}
You can’t perform that action at this time.
0 commit comments