Files
homelab/active/software_osbuild/image_builder.md

2.3 KiB

Image Builder

Builds Fedora/RHEL/Centos images like Packer but for Red Hat.

https://osbuild.org/docs/user-guide/blueprint-reference/

Default credentials for included images is:

username: ducoterra

password: osbuild

Warning

From the Red Hat Documentation:

You cannot build an operating system image that differs from the RHEL image builder host. For example, you cannot use a RHEL system to build Fedora or CentOS images.

Installing

# Install the packages
dnf install -y osbuild-composer composer-cli

# Start/enable the service
systemctl enable --now osbuild-composer.socket

# Optional: add your user to the weldr group
sudo usermod -aG weldr $USER

# Optional: cockpit dependency
dnf install -y cockpit-composer

Building Images

  1. Create a toml file describing your image

    See fedora-42-base.toml for an example.

  2. Push the toml to composer

    composer-cli blueprints push active/software_osbuild/fedora-42-base.toml
    
    # List blueprints
    composer-cli blueprints list
    
  3. Generate the image

    # List image types
    composer-cli compose types
    
    # Build the image
    composer-cli compose start fedora-42-base qcow2
    
    # Check status
    watch composer-cli compose status
    
    # Download logs if error
    cd /tmp && composer-cli compose logs f91a12b6-01fd-4f94-91cc-9d5fb68b8129
    
    # Delete failed images
    composer-cli compose list failed -j | jq '.[].body.failed.[]?.id' | xargs -I '%' composer-cli compose delete '%'
    
    # Delete successful images
    composer-cli compose list finished -j | jq '.[].body.finished.[]?.id' | xargs -I '%' composer-cli compose delete '%'
    
  4. Run the image

    # List your images
    composer-cli compose list finished
    
    # Download the image
    composer-cli compose image --filename /var/lib/libvirt/images/fedora-42-base.qcow2 image-uuid
    
    # Test with qemu
    qemu-kvm --name test-fedora-42-base -m 4096 -hda ~/Downloads/fedora-42-base.qcow2
    

Image Build and Watch One Liner

composer-cli blueprints push active/software_osbuild/fedora-43-base.toml && \
composer-cli compose start fedora-43-base qcow2 && \
watch composer-cli compose status