Skip to content

Commit 6fda71a

Browse files
committed
base_image: add SELinux relabeling for Fedora virt-builder images
Fedora guest images created on Debian hosts fail to boot because the filesystem lacks proper SELinux contexts. All binaries fail with exit code 127 (command not found) as SELinux blocks execution of files with unlabeled_t context. Add --selinux-relabel flag to virt-builder invocations when building Fedora images. This flag applies correct SELinux contexts during image creation, before first boot, ensuring all files have proper contexts when Fedora starts. The flag is conditionally added only for Fedora guests using Jinja2 conditionals in the task's argv parameter. This allows Fedora guests to boot successfully when provisioned from non-SELinux hosts. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]>
1 parent 88f94e7 commit 6fda71a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
- "raw"
5050
- "--commands-from-file"
5151
- "{{ command_file.path }}"
52+
- "{{ '--selinux-relabel' if (guestfs_fedora is defined and guestfs_fedora|bool) else '' }}"
5253
creates: "{{ base_image_pathname }}"
5354
when:
5455
- libvirt_uri_system|bool
@@ -68,6 +69,7 @@
6869
- "raw"
6970
- "--commands-from-file"
7071
- "{{ command_file.path }}"
72+
- "{{ '--selinux-relabel' if (guestfs_fedora is defined and guestfs_fedora|bool) else '' }}"
7173
creates: "{{ base_image_pathname }}"
7274
when:
7375
- not libvirt_uri_system|bool

0 commit comments

Comments
 (0)