Skip to content

Commit e676910

Browse files
committed
guestfs: fix checksum verification for resized custom images
The SHA512 checksum verification was failing because it was being run after the image had been resized and modified. The checksum from the upstream source is only valid for the original downloaded image, not the modified version. Fix by: 1. Verifying the checksum immediately after download, before any modifications 2. Removing the redundant checksum verification that happened after resize operations This ensures the image integrity is verified when downloaded, but doesn't fail on subsequent runs when the image has been customized for kdevops use. Error was: sha512sum: WARNING: 1 computed checksum did NOT match debian-13-generic-amd64-daily.raw: FAILED Generated-by: Claude AI Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 3e6b60f commit e676910

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

playbooks/roles/base_image/tasks/custom-image.yml

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@
4646
- not custom_image_stat.stat.exists
4747
- guestfs_has_custom_raw_image_url|bool
4848

49+
- name: Verify custom image checksum immediately after download
50+
when:
51+
- custom_image_download is changed
52+
- guestfs_has_custom_raw_image_sha512sums|bool
53+
block:
54+
- name: Get the base name of the sha512sums file for verification
55+
ansible.builtin.set_fact:
56+
sha512sums_file: "{{ guestfs_custom_raw_image_sha512sums_url | basename }}"
57+
58+
- name: Fetch the sha512sums file for verification
59+
become: true
60+
become_method: ansible.builtin.sudo
61+
ansible.builtin.get_url:
62+
url: "{{ guestfs_custom_raw_image_sha512sums_url }}"
63+
dest: "{{ custom_image_dir }}"
64+
mode: "u=rw,g=r,o=r"
65+
66+
- name: Verify checksum of freshly downloaded image
67+
ansible.builtin.command:
68+
cmd: "sha512sum --ignore-missing -c {{ sha512sums_file }}"
69+
chdir: "{{ custom_image_dir }}"
70+
changed_when: false
71+
4972
- name: Resize custom image to match configured size
5073
become: true
5174
become_method: ansible.builtin.sudo
@@ -104,42 +127,10 @@
104127
get_mime: false
105128
register: sentinel_stat
106129

107-
- name: Check the custom image
130+
- name: Configure custom image with kdevops settings
108131
when:
109132
- not sentinel_stat.stat.exists
110-
- guestfs_has_custom_raw_image_sha512sums|bool
111133
block:
112-
- name: Get the base name of the sha512sums file
113-
ansible.builtin.set_fact:
114-
sha512sums_file: "{{ guestfs_custom_raw_image_sha512sums_url | basename }}"
115-
116-
- name: Set the full pathname of sha512sums file
117-
ansible.builtin.set_fact:
118-
custom_image_sha512sum: "{{ custom_image_dir }}/{{ sha512sums_file }}"
119-
120-
- name: Check if the sha512sums file already exists
121-
ansible.builtin.stat:
122-
path: "{{ custom_image_sha512sum }}"
123-
get_attributes: false
124-
get_checksum: false
125-
get_mime: false
126-
register: sha512sums_stat
127-
128-
- name: Fetch the sha512sums file
129-
become: true
130-
become_method: ansible.builtin.sudo
131-
ansible.builtin.get_url:
132-
url: "{{ guestfs_custom_raw_image_sha512sums_url }}"
133-
dest: "{{ custom_image_dir }}"
134-
mode: "u=rw,g=r,o=r"
135-
when:
136-
- not sha512sums_stat.stat.exists
137-
138-
- name: Compute checksum of something
139-
ansible.builtin.command:
140-
cmd: "sha512sum --ignore-missing -c {{ sha512sums_file }}"
141-
chdir: "{{ custom_image_dir }}"
142-
changed_when: false
143134

144135
- name: Get the UID of the kdevops user on the control host
145136
ansible.builtin.command:

0 commit comments

Comments
 (0)