Skip to content

Commit 44468d4

Browse files
committed
base_image: add become privileges for custom image setup
Add become: true to tasks that require elevated privileges: - Directory creation in libvirt storage path - Writing to /etc/virt-builder/repos.d/ This fixes permission errors in CI environments where these operations need root privileges to access system directories. Fixes PermissionError when creating custom image directories. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]>
1 parent 3a8e0f0 commit 44468d4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
custom_image_dir: "{{ kdevops_storage_pool_path }}/guestfs/custom_images/{{ base_image_os_version }}"
55

66
- name: Ensure the custom image directory exists
7+
become: true
78
ansible.builtin.file:
89
path: "{{ custom_image_dir }}"
910
state: directory
@@ -34,6 +35,8 @@
3435
register: custom_image_stat
3536

3637
- name: Fetch the custom image
38+
become: true
39+
become_method: ansible.builtin.sudo
3740
ansible.builtin.get_url:
3841
url: "{{ guestfs_custom_raw_image_url }}"
3942
dest: "{{ custom_image_dir }}"
@@ -72,6 +75,8 @@
7275
register: sha512sums_stat
7376

7477
- name: Fetch the sha512sums file
78+
become: true
79+
become_method: ansible.builtin.sudo
7580
ansible.builtin.get_url:
7681
url: "{{ guestfs_custom_raw_image_sha512sums_url }}"
7782
dest: "{{ custom_image_dir }}"
@@ -158,6 +163,8 @@
158163
- not sentinel_stat.stat.exists
159164

160165
- name: Touch the custom image sentinel
166+
become: true
167+
become_method: ansible.builtin.sudo
161168
ansible.builtin.file:
162169
path: "{{ custom_image_ok }}"
163170
state: touch
@@ -172,6 +179,7 @@
172179
register: custom_source_stat
173180

174181
- name: Build the custom source
182+
become: true
175183
ansible.builtin.template:
176184
src: "{{ role_path }}/templates/custom-source.j2"
177185
dest: "{{ custom_source }}"
@@ -188,6 +196,8 @@
188196
register: custom_index_stat
189197

190198
- name: Build the custom index
199+
become: true
200+
become_method: ansible.builtin.sudo
191201
ansible.builtin.template:
192202
src: "{{ role_path }}/templates/custom-index.j2"
193203
dest: "{{ custom_index }}"
@@ -223,6 +233,8 @@
223233
Custom virt-builder image: {{ custom_image }}
224234
225235
- name: Generating the index for {{ base_image_os_version }}
236+
become: true
237+
become_method: ansible.builtin.sudo
226238
ansible.builtin.command:
227239
argv:
228240
- "virt-builder-repository"

0 commit comments

Comments
 (0)