Skip to content

Commit a5a119d

Browse files
committed
base_image: custom-image: fix variable scoping conflicts
Replace all instances of 'register: result' with descriptive variable names to prevent Ansible variable scoping conflicts that cause task failures. This prevents conditional logic from referencing wrong stat results and eliminates race conditions in task execution. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]
1 parent 7f642a2 commit a5a119d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
get_attributes: false
3232
get_checksum: false
3333
get_mime: false
34-
register: result
34+
register: custom_image_stat
3535

3636
- name: Fetch the custom image
3737
ansible.builtin.get_url:
3838
url: "{{ guestfs_custom_raw_image_url }}"
3939
dest: "{{ custom_image_dir }}"
4040
mode: "u=rw,g=r,o=r"
4141
when:
42-
- not result.stat.exists
42+
- not custom_image_stat.stat.exists
4343
- guestfs_has_custom_raw_image_url|bool
4444

4545
- name: Check if the custom image sentinel file already exists
@@ -48,11 +48,11 @@
4848
get_attributes: false
4949
get_checksum: false
5050
get_mime: false
51-
register: result
51+
register: sentinel_stat
5252

5353
- name: Check the custom image
5454
when:
55-
- not result.stat.exists
55+
- not sentinel_stat.stat.exists
5656
- guestfs_has_custom_raw_image_sha512sums|bool
5757
block:
5858
- name: Get the base name of the sha512sums file
@@ -69,15 +69,15 @@
6969
get_attributes: false
7070
get_checksum: false
7171
get_mime: false
72-
register: result
72+
register: sha512sums_stat
7373

7474
- name: Fetch the sha512sums file
7575
ansible.builtin.get_url:
7676
url: "{{ guestfs_custom_raw_image_sha512sums_url }}"
7777
dest: "{{ custom_image_dir }}"
7878
mode: "u=rw,g=r,o=r"
7979
when:
80-
- not result.stat.exists
80+
- not sha512sums_stat.stat.exists
8181

8282
- name: Compute checksum of something
8383
ansible.builtin.command:
@@ -97,31 +97,31 @@
9797
get_attributes: false
9898
get_checksum: false
9999
get_mime: false
100-
register: result
100+
register: custom_source_stat
101101

102102
- name: Build the custom source
103103
ansible.builtin.template:
104104
src: "{{ role_path }}/templates/custom-source.j2"
105105
dest: "{{ custom_source }}"
106106
mode: "u=rw,g=r,o=r"
107107
when:
108-
- not result.stat.exists
108+
- not custom_source_stat.stat.exists
109109

110110
- name: Check if the custom index exists
111111
ansible.builtin.stat:
112112
path: "{{ custom_index }}"
113113
get_attributes: false
114114
get_checksum: false
115115
get_mime: false
116-
register: result
116+
register: custom_index_stat
117117

118118
- name: Build the custom index
119119
ansible.builtin.template:
120120
src: "{{ role_path }}/templates/custom-index.j2"
121121
dest: "{{ custom_index }}"
122122
mode: "u=rw,g=r,o=r"
123123
when:
124-
- not result.stat.exists
124+
- not custom_index_stat.stat.exists
125125

126126
- name: Show rolling distribution release warning
127127
ansible.builtin.debug:

0 commit comments

Comments
 (0)