Chapter 9. Composing a customized RHEL system image


9.1. RHEL image builder description

To deploy a system, create a system image. To create RHEL system images, use the RHEL image builder tool. You can use RHEL image builder to create customized system images of RHEL, including system images prepared for deployment on cloud platforms. RHEL image builder automatically handles the setup details for each output type and is therefore easier to use and faster to work with than manual methods of image creation. You can access the RHEL image builder functionalities by using the command line in the composer-cli tool, or the graphical user interface in the RHEL web console.

Note

From RHEL 8.3 onward, the osbuild-composer back end replaces lorax-composer. The new service provides REST APIs for image building.

9.1.1. RHEL image builder terminology

RHEL image builder uses the following concepts:

Blueprint

A blueprint is a description of a customized system image. It lists the packages and customizations that will be part of the system. You can edit blueprints with customizations and save them as a particular version. When you create a system image from a blueprint, the image is associated with the blueprint in the RHEL image builder interface.

Create blueprints in the TOML format.

Compose
Composes are individual builds of a system image, based on a specific version of a particular blueprint. Compose as a term refers to the system image, the logs from its creation, inputs, metadata, and the process itself.
Customizations
Customizations are specifications for the image that are not packages. This includes users, groups, and SSH keys.

9.1.2. RHEL image builder output formats

RHEL image builder can create images in multiple output formats shown in the following table.

Expand
Table 9.1. RHEL image builder output formats
DescriptionCLI nameFile extension

QEMU Image

qcow2

.qcow2

Disk Archive

tar

.tar

Amazon Web Services

raw

.raw

Microsoft Azure

vhd

.vhd

Google Cloud Platform

gce

.tar.gz

VMware vSphere

vmdk

.vmdk

VMware vSphere

ova

.ova

Openstack

openstack

.qcow2

RHEL for Edge Commit

edge-commit

.tar

RHEL for Edge Container

edge-container

.tar

RHEL for Edge Installer

edge-installer

.iso

RHEL for Edge Raw Image

edge-raw-image

.raw.xz

RHEL for Edge Simplified Installer

edge-simplified-installer

.iso

RHEL for Edge AMI

edge-ami

.ami

RHEL for Edge VMDK

edge-vsphere

.vmdk

RHEL Installer

image-installer

.iso

Oracle Cloud Infrastructure

.oci

.qcow2

To check the supported types, run the command:

# composer-cli compose types
Copy to Clipboard Toggle word wrap

9.1.3. Supported architectures for image builds

RHEL image builder supports building images for the following architectures:

  • AMD and Intel 64-bit (x86_64)
  • ARM64 (aarch64)
  • IBM Z (s390x)
  • IBM POWER systems

However, RHEL image builder does not support multi-architecture builds. It only builds images of the same system architecture that it is running on. For example, if RHEL image builder is running on an x86_64 system, it can only build images for the x86_64 architecture.

9.2. Installing RHEL image builder

RHEL image builder is a tool for creating custom system images. Before using RHEL image builder, you must install it.

9.2.1. RHEL image builder system requirements

The host that runs RHEL image builder must meet the following requirements:

Expand
Table 9.2. RHEL image builder system requirements
ParameterMinimal Required Value

System type

A dedicated host or virtual machine. Note that RHEL image builder is not supported in containers, including Red Hat Universal Base Images (UBI).

Processor

2 cores

Memory

4 GiB

Disk space

20 GiB of free space in the ` /var/cache/` filesystem

Access privileges

root

Network

Internet connectivity to the Red Hat Content Delivery Network (CDN).

Note

If you do not have internet connectivity, use RHEL image builder in isolated networks. For that, you must override the default repositories to point to your local repositories to not connect to Red Hat Content Delivery Network (CDN). Ensure that you have your content mirrored internally or use Red Hat Satellite.

9.2.2. Installing RHEL image builder

Install RHEL image builder to have access to all the osbuild-composer package functionalities.

Prerequisites

  • You are logged in to the RHEL host on which you want to install RHEL image builder.
  • The host is subscribed to Red Hat Subscription Manager (RHSM) or Red Hat Satellite.
  • You have enabled the BaseOS and AppStream repositories to be able to install the RHEL image builder packages.

Procedure

  1. Install RHEL image builder and other necessary packages:

    # yum install osbuild-composer composer-cli cockpit-composer
    Copy to Clipboard Toggle word wrap
    • osbuild-composer - A service to build customized RHEL operating system images.
    • composer-cli- This package enables access to the CLI interface.
    • cockpit-composer - This package enables access to the Web UI interface. The web console is installed as a dependency of the cockpit-composer package.
  2. Enable and start RHEL image builder socket:

    # systemctl enable --now osbuild-composer.socket
    Copy to Clipboard Toggle word wrap
  3. If you want to use RHEL image builder in the web console, enable and start it.

    # systemctl enable --now cockpit.socket
    Copy to Clipboard Toggle word wrap

    The osbuild-composer and cockpit services start automatically on first access.

  4. Load the shell configuration script so that the autocomplete feature for the composer-cli command starts working immediately without logging out and in:

    $ source /etc/bash_completion.d/composer-cli
    Copy to Clipboard Toggle word wrap
Important

The osbuild-composer package is the new backend engine that will be the preferred default and focus of all new functionality beginning with Red Hat Enterprise Linux 8.3 and later. The previous backend lorax-composer package is considered deprecated, will only receive select fixes for the remainder of the Red Hat Enterprise Linux 8 life cycle and will be omitted from future major releases. It is recommended to uninstall lorax-composer in favor of osbuild-composer.

Verification

  • Verify that the installation works by running composer-cli:

    # composer-cli status show
    Copy to Clipboard Toggle word wrap

Troubleshooting

You can use a system journal to track RHEL image builder activities. Additionally, you can find the log messages in the file.

  • To find the journal output for traceback, run the following commands:

    $ journalctl | grep osbuild
    Copy to Clipboard Toggle word wrap
  • To show the local worker, such as the osbuild-worker@.service, a template service that can start multiple service instances:

    $ journalctl -u osbuild-worker*
    Copy to Clipboard Toggle word wrap
  • To show the running services:

    $ journalctl -u osbuild-composer.service
    Copy to Clipboard Toggle word wrap

The osbuild-composer backend, though much more extensible, does not currently achieve feature parity with the previous lorax-composer backend.

To revert to the previous backend, follow the steps:

Prerequisites

  • You have installed the osbuild-composer package

Procedure

  1. Remove the osbuild-composer backend.

    # yum remove osbuild-composer
    # yum remove weldr-client
    Copy to Clipboard Toggle word wrap
  2. In the /etc/yum.conf file, add an exclude entry for osbuild-composer package.

    # cat /etc/yum.conf
    [main]
    gpgcheck=1
    installonly_limit=3
    clean_requirements_on_remove=True
    best=True
    skip_if_unavailable=False
    exclude=osbuild-composer weldr-client
    Copy to Clipboard Toggle word wrap
  3. Install the lorax-composer package.

    # yum install lorax-composer composer-cli
    Copy to Clipboard Toggle word wrap
  4. Enable and start the lorax-composer service to start after each reboot.

    # systemctl enable --now lorax-composer.socket
    # systemctl start lorax-composer
    Copy to Clipboard Toggle word wrap

RHEL image builder is a tool for creating custom system images. To control RHEL image builder and create your custom system images, you can use the command line (CLI) or the web console interface.

You can use the RHEL image builder command-line interface (CLI) to create blueprints, by running the composer-cli command with the suitable options and subcommands.

The workflow for the command line can be summarized as follows:

  1. Create a blueprint or export (save) an existing blueprint definition to a plain text file
  2. Edit this file in a text editor
  3. Import the blueprint text file back into image builder
  4. Run a compose to build an image from the blueprint
  5. Export the image file to download it

Apart from the basic subcommands to create a blueprint, the composer-cli command offers many subcommands to examine the state of configured blueprints and composes.

9.3.2. Using RHEL image builder as a non-root user

To run the composer-cli commands as non-root, the user must be in the weldr group.

Prerequisites

  • You have created a user

Procedure

  • To add a user to the weldr or root groups, run the following commands:

    $ sudo usermod -a -G weldr user
    $ newgrp weldr
    Copy to Clipboard Toggle word wrap

You can create a new blueprint by using the RHEL image builder command-line interface (CLI). The blueprint describes the final image and its customizations, such as packages, and kernel customizations.

Prerequisites

  • You are logged in as the root user or a user who is a member of the weldr group

Procedure

  1. Create a plain text file with the following contents:

    name = "BLUEPRINT-NAME"
    description = "LONG FORM DESCRIPTION TEXT"
    version = "0.0.1"
    modules = []
    groups = []
    Copy to Clipboard Toggle word wrap

    Replace BLUEPRINT-NAME and LONG FORM DESCRIPTION TEXT with a name and description for your blueprint.

    Replace 0.0.1 with a version number according to the Semantic Versioning scheme.

  2. For every package that you want to be included in the blueprint, add the following lines to the file:

    [[packages]]
    name = "package-name"
    version = "package-version"
    Copy to Clipboard Toggle word wrap

    Replace package-name with the name of the package, such as httpd, gdb-doc, or coreutils.

    Optionally, replace package-version with the version to use. This field supports dnf version specifications:

    • For a specific version, use the exact version number such as 8.7.0.
    • For the latest available version, use the asterisk *.
    • For the latest minor version, use formats such as 8.*.
  3. Customize your blueprints to suit your needs. For example, disable Simultaneous Multi Threading (SMT), add the following lines to the blueprint file:

    [customizations.kernel]
    append = "nosmt=force"
    Copy to Clipboard Toggle word wrap

    For additional customizations available, see Supported Image Customizations.

    Note that [] and [[]] are different data structures expressed in TOML.

    • The [customizations.kernel] header represents a single table that is defined by a collection of keys and their respective value pairs, for example: append = "nosmt=force".
    • The [[packages]] header represents an array of tables. The first instance defines the array and its first table element, for example, name = "package-name" and version = "package-version", and each subsequent instance creates and defines a new table element in that array, in the order that you defined them.
  4. Save the file, for example, as BLUEPRINT-NAME.toml and close the text editor.
  5. Optional: Check if all settings from the Blueprint TOML file have been correctly parsed. Save the blueprint and compare the saved output with the input file:

    # composer-cli blueprints save BLUEPRINT-NAME.toml
    Copy to Clipboard Toggle word wrap
    1. Compare the BLUEPRINT-NAME.toml saved file with the input file.
  6. Push the blueprint:

    # composer-cli blueprints push BLUEPRINT-NAME.toml
    Copy to Clipboard Toggle word wrap

    Replace BLUEPRINT-NAME with the value you used in previous steps.

    Note

    To create images using composer-cli as non-root, add your user to the weldr or root groups.

    # usermod -a -G weldr user
    $ newgrp weldr
    Copy to Clipboard Toggle word wrap

Verification

  • List the existing blueprints to verify that the blueprint has been pushed and exists:

    # composer-cli blueprints list
    Copy to Clipboard Toggle word wrap
  • Display the blueprint configuration you have just added:

    # composer-cli blueprints show BLUEPRINT-NAME
    Copy to Clipboard Toggle word wrap
  • Check whether the components and versions listed in the blueprint and their dependencies are valid:

    # composer-cli blueprints depsolve BLUEPRINT-NAME
    Copy to Clipboard Toggle word wrap

    If RHEL image builder is unable to solve the dependencies of a package from your custom repositories, remove the osbuild-composer cache:

    $ sudo rm -rf /var/cache/osbuild-composer/*
    $ sudo systemctl restart osbuild-composer
    Copy to Clipboard Toggle word wrap

You can edit an existing blueprint on the command line (CLI) to, for example, add a new package, or define a new group, and to create your customized images.

Prerequisites

  • You have created a blueprint

Procedure

  1. List the existing blueprints:

    # composer-cli blueprints list
    Copy to Clipboard Toggle word wrap
  2. Save the blueprint to a local text file:

    # composer-cli blueprints save BLUEPRINT-NAME
    Copy to Clipboard Toggle word wrap
  3. Edit the BLUEPRINT-NAME.toml file with a text editor and make your changes.
  4. Before finishing the edits, verify that the file is a valid blueprint:

    1. Remove the following line from the blueprint, if present:

      packages = []
      Copy to Clipboard Toggle word wrap
    2. Increase the version number, for example, from 0.0.1 to 0.1.0. Remember that RHEL image builder blueprint versions must use the Semantic Versioning scheme. Note also that if you do not change the version, the patch version component increases automatically.
  5. Save the file and close the text editor.
  6. Push the blueprint back into RHEL image builder:

    # composer-cli blueprints push BLUEPRINT-NAME.toml
    Copy to Clipboard Toggle word wrap
    Note

    To import the blueprint back into RHEL image builder, supply the file name including the .toml extension, while in other commands use only the blueprint name.

Verification

  1. To verify that the contents uploaded to RHEL image builder match your edits, list the contents of blueprint:

    # composer-cli blueprints show BLUEPRINT-NAME
    Copy to Clipboard Toggle word wrap
  2. Check whether the components and versions listed in the blueprint and their dependencies are valid:

    # composer-cli blueprints depsolve BLUEPRINT-NAME
    Copy to Clipboard Toggle word wrap

You can build a customized RHEL image by using the RHEL image builder command-line interface. For that, you must specify a blueprint and an image type. Optionally, you can also specify a distribution. If you do not specify a distribution, it will use the same distribution and version as the host system. The architecture is also the same as the one on the host.

Prerequisites

Procedure

  1. Optional: List the image formats you can create:

    # composer-cli compose types
    Copy to Clipboard Toggle word wrap
  2. Start the compose:

    # composer-cli compose start BLUEPRINT-NAME IMAGE-TYPE
    Copy to Clipboard Toggle word wrap

    Replace BLUEPRINT-NAME with the name of the blueprint, and IMAGE-TYPE with the type of the image. For the available values, see the output of the composer-cli compose types command.

    The compose process starts in the background and shows the composer Universally Unique Identifier (UUID).

  3. The image creation can take up to ten minutes to complete.

    To check the status of the compose:

    # composer-cli compose status
    Copy to Clipboard Toggle word wrap

    A finished compose shows the FINISHED status value. To identify your compose in the list, use its UUID.

  4. After the compose process is finished, download the resulting image file:

    # composer-cli compose image UUID
    Copy to Clipboard Toggle word wrap

    Replace UUID with the UUID value shown in the previous steps.

Verification

After you create your image, you can check the image creation progress by using the following commands:

  • Download the metadata of the image to get a .tar file of the metadata for the compose:

    $ sudo composer-cli compose metadata UUID
    Copy to Clipboard Toggle word wrap
  • Download the logs of the image:

    $ sudo composer-cli compose logs UUID
    Copy to Clipboard Toggle word wrap

    The command creates a .tar file that contains the logs for the image creation. If the logs are empty, you can check the journal.

  • Check the journal:

    $ journalctl | grep osbuild
    Copy to Clipboard Toggle word wrap
  • Check the manifest of the image:

    $ sudo cat /var/lib/osbuild-composer/jobs/job_UUID.json
    Copy to Clipboard Toggle word wrap

    You can find the job_UUID.json in the journal.

The RHEL image builder command-line interface offers the following subcommands.

Blueprint manipulation

List all available blueprints
# composer-cli blueprints list
Copy to Clipboard Toggle word wrap
Show a blueprint contents in the TOML format
# composer-cli blueprints show <BLUEPRINT-NAME>
Copy to Clipboard Toggle word wrap
Save (export) blueprint contents in the TOML format into a file BLUEPRINT-NAME.toml
# composer-cli blueprints save <BLUEPRINT-NAME>
Copy to Clipboard Toggle word wrap
Remove a blueprint
# composer-cli blueprints delete <BLUEPRINT-NAME>
Copy to Clipboard Toggle word wrap
Push (import) a blueprint file in the TOML format into RHEL image builder
# composer-cli blueprints push <BLUEPRINT-NAME>
Copy to Clipboard Toggle word wrap

Composing images from blueprints

List the available image types
# composer-cli compose types
Copy to Clipboard Toggle word wrap
Start a compose
# composer-cli compose start <BLUEPRINT> <COMPOSE-TYPE>
Copy to Clipboard Toggle word wrap
List all composes
# composer-cli compose list
Copy to Clipboard Toggle word wrap
List all composes and their status
# composer-cli compose status
Copy to Clipboard Toggle word wrap
Cancel a running compose
# composer-cli compose cancel <COMPOSE-UUID>
Copy to Clipboard Toggle word wrap
Delete a finished compose
# composer-cli compose delete <COMPOSE-UUID>
Copy to Clipboard Toggle word wrap
Show detailed information about a compose
# composer-cli compose info <COMPOSE-UUID>
Copy to Clipboard Toggle word wrap
Download image file of a compose
# composer-cli compose image <COMPOSE-UUID>
Copy to Clipboard Toggle word wrap
See more subcommands and options
# composer-cli help
Copy to Clipboard Toggle word wrap

9.3.7. RHEL image builder blueprint format

RHEL image builder blueprints are presented to the user as plain text in the TOML format.

The elements of a typical blueprint file include the following:

The blueprint metadata
name = "<BLUEPRINT-NAME>"
description = "<LONG FORM DESCRIPTION TEXT>"
version = "<VERSION>"
Copy to Clipboard Toggle word wrap

The BLUEPRINT-NAME and LONG FORM DESCRIPTION TEXT field are a name and description for your blueprint.

The VERSION is a version number according to the Semantic Versioning scheme, and is present only once for the entire blueprint file.

Groups to include in the image
[[groups]]
name = "group-name"
Copy to Clipboard Toggle word wrap

The group entry describes a group of packages to be installed into the image. Groups use the following package categories:

  • Mandatory
  • Default
  • Optional

    The group-name is the name of the group, for example, anaconda-tools, widget, wheel or users. Blueprints install the mandatory and default packages. There is no mechanism for selecting optional packages.

Packages to include in the image
[[packages]]
name = "<package-name>"
version = "<package-version>"
Copy to Clipboard Toggle word wrap

package-name is the name of the package, such as httpd, gdb-doc, or coreutils.

package-version is a version to use. This field supports dnf version specifications:

  • For a specific version, use the exact version number such as 8.7.0.
  • For latest available version, use the asterisk *.
  • For a latest minor version, use a format such as 8.*.

    Repeat this block for every package to include.

Note

There are no differences between packages and modules in the RHEL image builder tool. Both are treated as RPM package dependencies.

9.3.8. Supported image customizations

You can customize your image by adding customizations to your blueprint, such as:

  • Adding an additional RPM package
  • Enabling a service
  • Customizing a kernel command line parameter.

Between others. You can use several image customizations within blueprints. By using the customizations, you can add packages and groups to the image that are not available in the default packages. To use these options, configure the customizations in the blueprint and import (push) it to RHEL image builder.

9.3.8.1. Selecting a distribution

You can use the distro field to specify the distribution to use when composing your images or solving dependencies in the blueprint. If the distro field is left blank, the blueprint automatically uses the host’s operating system distribution. If you do not specify a distribution, the blueprint uses the host distribution. When you upgrade the host operating system, blueprints without a specified distribution build images by using the upgraded operating system version.

You can build images for older major versions on a newer system. For example, you can use a RHEL 10 host to create RHEL 9 and RHEL 8 images. However, you cannot build images for newer major versions on an older system.

Important

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.

  • Customize the blueprint with the RHEL distribution to always build the specified RHEL image:

    name = "blueprint_name"
    description = "blueprint_version"
    version = "0.1"
    distro = "different_minor_version"
    Copy to Clipboard Toggle word wrap

    For example:

    name = "tmux"
    description = "tmux image with openssh"
    version = "1.2.16"
    distro = "rhel-9.5"
    Copy to Clipboard Toggle word wrap

Replace "different_minor_version" to build a different minor version, for example, if you want to build a RHEL 8.10 image, use distro = "rhel-810". On RHEL 8.10 image, you can build minor versions such as RHEL 8.9 and earlier releases.

9.3.8.2. Selecting a package group

Customize the blueprint with package groups. The groups list describes the groups of packages that you want to install into the image. The package groups are defined in the repository metadata. Each group has a descriptive name that is used primarily for display in user interfaces, and an ID that is commonly used in Kickstart files. In this case, you must use the ID to list a group. Groups have three different ways of categorizing their packages: mandatory, default, and optional. Only mandatory and default packages are installed in the blueprints. It is not possible to select optional packages.

The name attribute is a required string and must match exactly the package group id in the repositories.

Note

Currently, there are no differences between packages and modules in osbuild-composer. Both are treated as an RPM package dependency.

  • Customize your blueprint with a package:

    [[groups]]
    name = "group_name"
    Copy to Clipboard Toggle word wrap

    Replace group_name with the name of the group. For example, anaconda-tools:

    [[groups]]
    name = "anaconda-tools"
    Copy to Clipboard Toggle word wrap

9.3.8.3. Embedding a container

You can customize your blueprint to embed the latest RHEL container. The containers list contains objects with a source, and optionally, the tls-verify attribute.

The container list entries describe the container images to be embedded into the image.

  • source - Mandatory field. It is a reference to the container image at a registry. This example uses the registry.access.redhat.com registry. You can specify a tag version. The default tag version is latest.
  • name - The name of the container in the local registry.
  • tls-verify - Boolean field. The tls-verify boolean field controls the transport layer security. The default value is true.

The embedded containers do not start automatically. To start it, create systemd unit files or quadlets with the files customization.

  • To embed a container from registry.access.redhat.com/ubi9/ubi:latest and a container from your host, add the following customization to your blueprint:

    [[containers]]
    source = "registry.access.redhat.com/ubi9/ubi:latest"
    name =  "local-name"
    tls-verify = true
    
    [[containers]]
    source = "localhost/test:latest"
    local-storage = true
    Copy to Clipboard Toggle word wrap

You can access protected container resources by using a containers-auth.json file. See Container registry credentials.

9.3.8.4. Setting the image hostname

The customizations.hostname is an optional string that you can use to configure the final image hostname. This customization is optional, and if you do not set it, the blueprint uses the default hostname.

  • Customize the blueprint to configure the hostname:

    [customizations]
    hostname = "baseimage"
    Copy to Clipboard Toggle word wrap

9.3.8.5. Specifying additional users

Add a user to the image, and optionally, set their SSH key. All fields for this section are optional except for the name.

Procedure

  • Customize the blueprint to add a user to the image:

    [[customizations.user]]
    name = "USER-NAME"
    description = "USER-DESCRIPTION"
    password = "PASSWORD-HASH"
    key = "PUBLIC-SSH-KEY"
    home = "/home/USER-NAME/"
    shell = "/usr/bin/bash"
    groups = ["users", "wheel"]
    uid = NUMBER
    gid = NUMBER
    Copy to Clipboard Toggle word wrap
    [[customizations.user]]
    name = "admin"
    description = "Administrator account"
    password = "$6$CHO2$3rN8eviE2t50lmVyBYihTgVRHcaecmeCk31L..."
    key = "PUBLIC SSH KEY"
    home = "/srv/widget/"
    shell = "/usr/bin/bash"
    groups = ["widget", "users", "wheel"]
    uid = 1200
    gid = 1200
    expiredate = 12345
    Copy to Clipboard Toggle word wrap

    The GID is optional and must already exist in the image. Optionally, a package creates it, or the blueprint creates the GID by using the [[customizations.group]] entry.

    Replace PASSWORD-HASH with the actual password hash. To generate the password hash, use a command such as:

    $ python3 -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) if (pw==getpass.getpass("Confirm: ")) else exit())'
    Copy to Clipboard Toggle word wrap

    Replace the other placeholders with suitable values.

    Enter the name value and omit any lines you do not need.

    Repeat this block for every user to include.

9.3.8.6. Specifying additional groups

Specify a group for the resulting system image. Both the name and the gid attributes are mandatory.

  • Customize the blueprint with a group:

    [[customizations.group]]
    name = "GROUP-NAME"
    gid = NUMBER
    Copy to Clipboard Toggle word wrap

    Repeat this block for every group to include. For example:

    [[customizations.group]]
    name = "widget"
    gid = 1130
    Copy to Clipboard Toggle word wrap

9.3.8.7. Setting SSH key for existing users

You can use customizations.sshkey to set an SSH key for the existing users in the final image. Both user and key attributes are mandatory.

  • Customize the blueprint by setting an SSH key for existing users:

    [[customizations.sshkey]]
    user = "root"
    key = "PUBLIC-SSH-KEY"
    Copy to Clipboard Toggle word wrap

    For example:

    [[customizations.sshkey]]
    user = "root"
    key = "SSH key for root"
    Copy to Clipboard Toggle word wrap
    Note

    You can only configure the customizations.sshkey customization for existing users. To create a user and set an SSH key, see the Specifying additional users customization.

9.3.8.8. Appending a kernel argument

You can append arguments to the boot loader kernel command line. By default, RHEL image builder builds a default kernel into the image. However, you can customize the kernel by configuring it in the blueprint.

  • Append a kernel boot parameter option to the defaults:

    [customizations.kernel]
    append = "KERNEL-OPTION"
    Copy to Clipboard Toggle word wrap

    For example:

    [customizations.kernel]
    name = "kernel-debug"
    append = "nosmt=force"
    Copy to Clipboard Toggle word wrap

To build a RHEL image by using the real-time kernel (kernel-rt), you need to override a repository so that you can then build an image in which kernel-rt is correctly selected as the default kernel. Use the .json from the /usr/share/osbuild-composer/repositories/ directory. Then, you can deploy the image that you built to a system and use the real time kernel features.

Note

The real-time kernel runs on AMD64 and Intel 64 server platforms that are certified to run Red Hat Enterprise Linux.

Prerequisites

Procedure

  1. Create the following directory:

    # mkdir /etc/osbuild-composer/repositories/
    Copy to Clipboard Toggle word wrap
  2. Copy the content from the /usr/share/osbuild-composer/repositories/rhel-8.version.json file to the new directory:

    # cp /usr/share/osbuild-composer/repositories/rhel-8.version.json /etc/osbuild-composer/repositories
    Copy to Clipboard Toggle word wrap
  3. Edit the /etc/osbuild-composer/repositories/rhel-8.version.json file to include the RT kernel repo:

    # grep -C 6 kernel-rt /etc/osbuild-composer/repositories/rhel-8.version.json
          "baseurl": "https://cdn.redhat.com/content/dist/rhel8/8.version/x86_64/appstream/os",
          "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nm………..=\n=UZd/\n-----END PGP PUBLIC KEY BLOCK-----\n",
          "rhsm": true,
          "check_gpg": true
        },
        {
          "name": "kernel-rt",
          "baseurl": "https://cdn.redhat.com/content/dist/rhel8/8.version/x86_64/rt/os",
          "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBEr………fg==\n=UZd/\n-----END PGP PUBLIC KEY BLOCK-----\n",
          "rhsm": true,
          "check_gpg": true
        },
    Copy to Clipboard Toggle word wrap
  4. Restart the service:

    # systemctl restart osbuild-composer
    Copy to Clipboard Toggle word wrap
  5. Confirm that the kernel-rt has been included into the .json file:

    # composer-cli sources list
    # composer-cli sources info kernel-rt
    Copy to Clipboard Toggle word wrap

    You will see the URL that you have previously configured.

  6. Create a blueprint. In the blueprint, add the "[customizations.kernel]" customization. The following is an example that contains the "[customizations.kernel]" in the blueprint:

    name = "rt-kernel-image"
    description = ""
    version = "2.0.0"
    modules = []
    groups = []
    distro = "rhel-8_version_"
    [[customizations.user]]
    name = "admin"
    password = "admin"
    groups = ["users", "wheel"]
    [customizations.kernel]
    name = "kernel-rt"
    append = ""
    Copy to Clipboard Toggle word wrap
  7. Push the blueprint to the server:

    # composer-cli blueprints push rt-kernel-image.toml
    Copy to Clipboard Toggle word wrap
  8. Build your image from the blueprint you created. The following example builds a (.qcow2) image:

    # composer-cli compose start rt-kernel-image qcow2
    Copy to Clipboard Toggle word wrap
  9. Deploy the image that you built to the system where you want to use the real time kernel features.

Verification

  • After booting a VM from the image, verify that the image was built with the kernel-rt correctly selected as the default kernel.

    $ cat /proc/cmdline
    BOOT_IMAGE=(hd0,got3)/vmlinuz-5.14.0-362.24.1..el8_version_.x86_64+rt...
    Copy to Clipboard Toggle word wrap

9.3.8.10. Setting time zone and NTP

You can customize your blueprint to configure the time zone and the Network Time Protocol (NTP). Both timezone and ntpservers attributes are optional strings. If you do not customize the time zone, the system uses Universal Time, Coordinated (UTC). If you do not set NTP servers, the system uses the default distribution.

  • Customize the blueprint with the timezone and the ntpservers you want:

    [customizations.timezone]
    timezone = "TIMEZONE"
    ntpservers = "NTP_SERVER"
    Copy to Clipboard Toggle word wrap

    For example:

    [customizations.timezone]
    timezone = "US/Eastern"
    ntpservers = ["0.north-america.pool.ntp.org", "1.north-america.pool.ntp.org"]
    Copy to Clipboard Toggle word wrap
    Note

    Some image types, such as Google Cloud, already have NTP servers set up. You cannot override it because the image requires the NTP servers to boot in the selected environment. However, you can customize the time zone in the blueprint.

9.3.8.11. Customizing the locale settings

You can customize the locale settings for your resulting system image. Both language and the keyboard attributes are mandatory. You can add many other languages. The first language you add is the primary language and the other languages are secondary.

Procedure

  • Set the locale settings:

    [customizations.locale]
    languages = ["LANGUAGE"]
    keyboard = "KEYBOARD"
    Copy to Clipboard Toggle word wrap

    For example:

    [customizations.locale]
    languages = ["en_US.UTF-8"]
    keyboard = "us"
    Copy to Clipboard Toggle word wrap
  • To list the values supported by the languages, run the following command:

    $ localectl list-locales
    Copy to Clipboard Toggle word wrap
  • To list the values supported by the keyboard, run the following command:

    $ localectl list-keymaps
    Copy to Clipboard Toggle word wrap

9.3.8.12. Customizing firewall

Set the firewall for the resulting system image. By default, the firewall blocks incoming connections, except for services that enable their ports explicitly, such as sshd.

If you do not want to use the [customizations.firewall] or the [customizations.firewall.services], either remove the attributes, or set them to an empty list []. If you only want to use the default firewall setup, you can omit the customization from the blueprint.

Note

The Google and OpenStack templates explicitly disable the firewall for their environment. You cannot override this behavior by setting the blueprint.

Procedure

  • Customize the blueprint with the following settings to open other ports and services:

    [customizations.firewall]
    ports = ["PORTS"]
    Copy to Clipboard Toggle word wrap

    Where ports is an optional list of strings that contain ports or a range of ports and protocols to open. You can configure the ports by using the following format: port:protocol format. You can configure the port ranges by using the portA-portB:protocol format. For example:

    [customizations.firewall]
    ports = ["22:tcp", "80:tcp", "imap:tcp", "53:tcp", "53:udp", "30000-32767:tcp", "30000-32767:udp"]
    Copy to Clipboard Toggle word wrap

    You can use numeric ports, or their names from the /etc/services to enable or disable port lists.

  • Specify which firewall services to enable or disable in the customizations.firewall.service section:

    [customizations.firewall.services]
    enabled = ["SERVICES"]
    disabled = ["SERVICES"]
    Copy to Clipboard Toggle word wrap
  • You can check the available firewall services:

    $ firewall-cmd --get-services
    Copy to Clipboard Toggle word wrap

    For example:

    [customizations.firewall.services]
    enabled = ["ftp", "ntp", "dhcp"]
    disabled = ["telnet"]
    Copy to Clipboard Toggle word wrap
    Note

    The services listed in firewall.services are different from the service-names available in the /etc/services file.

9.3.8.13. Enabling or disabling services

You can control which services to enable during the boot time. Some image types already have services enabled or disabled to ensure that the image works correctly and you cannot override this setup. The [customizations.services] settings in the blueprint do not replace these services, but add the services to the list of services already present in the image templates.

  • Customize which services to enable during the boot time:

    [customizations.services]
    enabled = ["SERVICES"]
    disabled = ["SERVICES"]
    Copy to Clipboard Toggle word wrap

    For example:

    [customizations.services]
    enabled = ["sshd", "cockpit.socket", "httpd"]
    disabled = ["postfix", "telnetd"]
    Copy to Clipboard Toggle word wrap

You can use the [customization.installer] blueprint customization to add your own Kickstart file in your builds for ISO installers such as, image installer or edge installer, and gain more flexibility when building ISO images for bare-metal deployments.

Warning

Booting the ISO on a machine with an existing operating system or data can be destructive, because the Kickstart is configured to automatically reformat the first disk on the system.

You can choose the following options to add your own Kickstart file:

  • Setting all values during the installation process.
  • Enabling the unattended = true field in the Kickstart, and getting a fully unattended installation with defaults.
  • Injecting your own Kickstart by using the Kickstart field. This can result in both a fully unattended installation if you specify all required fields, or the Installer asks for some fields that might be missing.

The Anaconda installer ISO image types support the following blueprint customization:

[customizations.installer]
unattended = true
sudo-nopasswd = ["user", "%wheel"]
Copy to Clipboard Toggle word wrap

unattended: Creates a Kickstart file that makes the installation fully automatic. This includes setting the following options by default:

  • text display mode
  • en_US.UTF-8 language/locale
  • us keyboard layout
  • UTC timezone
  • zerombr, clearpart, and autopart to automatically wipe and partition the first disk
  • network options to enable dhcp and auto-activation

The following is an example:

liveimg --url file:///run/install/<_repo_>/liveimg.tar.gz
lang en_US.UTF-8
keyboard us
timezone UTC
zerombr
clearpart --all --initlabel
text
autopart --type=plain --fstype=xfs --nohome
reboot --eject
network --device=link --bootproto=dhcp --onboot=on --activate
Copy to Clipboard Toggle word wrap

sudo-nopasswd: Adds a snippet to the Kickstart file that, after installation, creates drop-in files in /etc/sudoers.d to allow the specified users and groups to run sudo without a password. The groups must be prefixed with %. For example, setting the value to ["user", "%wheel"] creates the following Kickstart %post section:

%post
echo -e "user\tALL=(ALL)\tNOPASSWD: ALL" > "/etc/sudoers.d/user"
chmod 0440 /etc/sudoers.d/user
echo -e "%wheel\tALL=(ALL)\tNOPASSWD: ALL" > "/etc/sudoers.d/%wheel"
chmod 0440 /etc/sudoers.d/%wheel
restorecon -rvF /etc/sudoers.d
%end
Copy to Clipboard Toggle word wrap

Installer Kickstart

As an alternative, you can include a custom Kickstart by using the following customization:

[customizations.installer.kickstart]
contents = """
text --non-interactive
zerombr
clearpart --all --initlabel --disklabel=gpt
autopart --noswap --type=lvm
network --bootproto=dhcp --device=link --activate --onboot=on
"""
Copy to Clipboard Toggle word wrap

osbuild-composer automatically adds the command that installs the system: liveimg or ostreesetup, if it is relevant for the image-installer, or edge-installer image types. You cannot use the [customizations.installer.kickstart] customization in combination with any other installer customizations.

9.3.8.15. Specifying a partition mode

Use the partitioning_mode variable to select how to partition the disk image that you are building. You can customize your image with the following supported modes:

  • auto-lvm: It uses the raw partition mode, unless there are one or more filesystem customizations. In that case, it uses the LVM partition mode.
  • lvm: It always uses the LVM partition mode, even when there are no extra mountpoints.
  • raw: It uses raw partitions even when there are one or more mountpoints.
  • You can customize your blueprint with the partitioning_mode variable by using the following customization:

    [customizations]
    partitioning_mode = "lvm"
    Copy to Clipboard Toggle word wrap

You can specify a custom file system configuration in your blueprints and therefore create images with a specific disk layout, instead of the default layout configuration. By using the non-default layout configuration in your blueprints, you can benefit from:

  • Security benchmark compliance
  • Protection against out-of-disk errors
  • Improved performance
  • Consistency with existing setups
Note

The OSTree systems do not support the file system customizations, because OSTree images have their own mount rule, such as read-only. The following image types are not supported:

  • image-installer
  • edge-installer
  • edge-simplified-installer

Additionally, the following image types do not support file system customizations, because these image types do not create partitioned operating system images:

  • edge-commit
  • edge-container
  • tar
  • container

However, the following image types have support for file system customization:

  • simplified-installer
  • edge-raw-image
  • edge-ami
  • edge-vsphere

With some additional exceptions for OSTree systems, you can choose arbitrary directory names at the /root level of the file system, for example: ` /local`,` /mypartition`, /$PARTITION. In logical volumes, these changes are made on top of the LVM partitioning system. The following directories are supported: /var,` /var/log`, and /var/lib/containers on a separate logical volume. The following are exceptions at root level:

  • "/home": {Deny: true},
  • "/mnt": {Deny: true},
  • "/opt": {Deny: true},
  • "/ostree": {Deny: true},
  • "/root": {Deny: true},
  • "/srv": {Deny: true},
  • "/var/home": {Deny: true},
  • "/var/mnt": {Deny: true},
  • "/var/opt": {Deny: true},
  • "/var/roothome": {Deny: true},
  • "/var/srv": {Deny: true},
  • "/var/usrlocal": {Deny: true},

For release distributions before RHEL 8.10 and 9.5, the blueprint supports the following mountpoints and their sub-directories:

  • / - the root mount point
  • /var
  • /home
  • /opt
  • /srv
  • /usr
  • /app
  • /data
  • /tmp

From the RHEL 9.5 and 8.10 release distributions onward, you can specify arbitrary custom mountpoints, except for specific paths that are reserved for the operating system.

You cannot specify arbitrary custom mountpoints on the following mountpoints and their sub-directories:

  • /bin
  • /boot/efi
  • /dev
  • /etc
  • /lib
  • /lib64
  • /lost+found
  • /proc
  • /run
  • /sbin
  • /sys
  • /sysroot
  • /var/lock
  • /var/run

You can customize the file system in the blueprint for the /usr custom mountpoint, but its subdirectory is not allowed.

Note

Customizing mount points is only supported from RHEL 8.5 distributions onward, by using the CLI. In earlier distributions, you can only specify the root partition as a mount point and specify the size argument as an alias for the image size. Beginning with RHEL 8.6, for the osbuild-composer-46.1-1.el8 RPM and later version, the physical partitions are no longer available and file system customizations create logical volumes.

If you have more than one partition in the customized image, you can create images with a customized file system partition on LVM and resize those partitions at runtime. To do this, you can specify a customized file system configuration in your blueprint and therefore create images with the required disk layout. The default file system layout remains unchanged - if you use plain images without file system customization, and cloud-init resizes the root partition.

The blueprint automatically converts the file system customization to an LVM partition.

You can use the custom file blueprint customization to create new files or to replace existing files. The parent directory of the file you specify must exist, otherwise, the image build fails. Ensure that the parent directory exists by specifying it in the [[customizations.directories]] customization.

Warning

If you combine the files customizations with other blueprint customizations, it might affect the functioning of the other customizations, or it might override the current files customizations.

With the [[customizations.files]] blueprint customization you can:

  • Create new text files.
  • Modifying existing files. WARNING: this can override the existing content.
  • Set user and group ownership for the file you are creating.
  • Set the mode permission in the octal format.

You cannot create or replace the following files:

  • /etc/fstab
  • /etc/shadow
  • /etc/passwd
  • /etc/group

You can create customized files and directories in your image, by using the [[customizations.files]] and the [[customizations.directories]] blueprint customizations. You can use these customizations only in the /etc directory.

Note

These blueprint customizations are supported by all image types, except the image types that deploy OSTree commits, such as edge-raw-image, edge-installer, and edge-simplified-installer.

Warning

If you use the customizations.directories with a directory path which already exists in the image with mode, user or group already set, the image build fails to prevent changing the ownership or permissions of the existing directory.

With the [[customizations.directories]] blueprint customization you can:

  • Create new directories.
  • Set user and group ownership for the directory you are creating.
  • Set the directory mode permission in the octal format.
  • Ensure that parent directories are created as needed.

With the [[customizations.files]] blueprint customization you can:

  • Create new text files.
  • Modifying existing files. WARNING: this can override the existing content.
  • Set user and group ownership for the file you are creating.
  • Set the mode permission in the octal format.
Note

You cannot create or replace the following files:

  • /etc/fstab
  • /etc/shadow
  • /etc/passwd
  • /etc/group

The following customizations are available:

  • Customize the file system configuration in your blueprint:

    [[customizations.filesystem]]
    mountpoint = "MOUNTPOINT"
    minsize = MINIMUM-PARTITION-SIZE
    Copy to Clipboard Toggle word wrap

    The MINIMUM-PARTITION-SIZE value has no default size format. The blueprint customization supports the following values and units: kB to TB and KiB to TiB. For example, you can define the mount point size in bytes:

    [[customizations.filesystem]]
    mountpoint = "/var"
    minsize = 1073741824
    Copy to Clipboard Toggle word wrap
  • Define the mount point size by using units. For example:

    [[customizations.filesystem]]
    mountpoint = "/opt"
    minsize = "20 GiB"
    Copy to Clipboard Toggle word wrap
    [[customizations.filesystem]]
    mountpoint = "/boot"
    minsize = "1 GiB"
    Copy to Clipboard Toggle word wrap
  • Define the minimum partition by setting minsize. For example:

    [[customizations.filesystem]]
    mountpoint = "/var"
    minsize = 2147483648
    Copy to Clipboard Toggle word wrap
  • Create customized directories under the /etc directory for your image by using [[customizations.directories]]:

    [[customizations.directories]]
    path = "/etc/directory_name"
    mode = "octal_access_permission"
    user = "user_string_or_integer"
    group = "group_string_or_integer"
    ensure_parents = boolean
    Copy to Clipboard Toggle word wrap

    The blueprint entries are described as following:

    • path - Mandatory - enter the path to the directory that you want to create. It must be an absolute path under the /etc directory.
    • mode - Optional - set the access permission on the directory, in the octal format. If you do not specify a permission, it defaults to 0755. The leading zero is optional.
    • user - Optional - set a user as the owner of the directory. If you do not specify a user, it defaults to root. You can specify the user as a string or as an integer.
    • group - Optional - set a group as the owner of the directory. If you do not specify a group, it defaults to root. You can specify the group as a string or as an integer.
    • ensure_parents - Optional - Specify whether you want to create parent directories as needed. If you do not specify a value, it defaults to false.
  • Create customized file under the /etc directory for your image by using [[customizations.directories]]:

    [[customizations.files]]
    path = "/etc/directory_name"
    mode = "octal_access_permission"
    user = "user_string_or_integer"
    group = "group_string_or_integer"
    data = "Hello world!"
    Copy to Clipboard Toggle word wrap

    The blueprint entries are described as following:

    • path - Mandatory - enter the path to the file that you want to create. It must be an absolute path under the /etc directory.
    • mode Optional - set the access permission on the file, in the octal format. If you do not specify a permission, it defaults to 0644. The leading zero is optional.
    • user - Optional - set a user as the owner of the file. If you do not specify a user, it defaults to root. You can specify the user as a string or as an integer.
    • group - Optional - set a group as the owner of the file. If you do not specify a group, it defaults to root. You can specify the group as a string or as an integer.
    • data - Optional - Specify the content of a plain text file. If you do not specify a content, it creates an empty file.

You can use RHEL image builder for the following operations:

  • Create RHEL disk images with advanced partitioning layout. You can create disk images with custom mount points, LVM-based partitions and LVM-based SWAP. For example, change the size of the / and the /boot directories by using the config.toml file.
  • Select which file system to use. You can choose between ext4 and xfs.
  • Add swap partitions and LVs. The disk images can contain LV-based SWAP.
  • Change names of LVM entities. The Logical Volumes (LV) and Volume Groups (VG) inside the images can have custom names.

The following options are not supported:

  • Multiple PVs or VGs in one image.
  • SWAP files
  • Mount options for non-physical partitions, such as /dev/shm, and /tmp.

Example: Adding the VG and LG customization names where the file systems reside.

[[customizations.disk.partitions]]
type = "plain"
label = "data"
mountpoint = "/data"
fs_type = "ext4"
minsize = "50 GiB"

[[customizations.disk.partitions]]
type = "lvm"
name = "mainvg"
minsize = "20 GiB"

[[customizations.disk.partitions.logical_volumes]]
name = "rootlv"
mountpoint = "/"
label = "root"
fs_type = "ext4"
minsize = "2 GiB"

[[customizations.disk.partitions.logical_volumes]]
name = "homelv"
mountpoint = "/home"
label = "home"
fs_type = "ext4"
minsize = "2 GiB"

[[customizations.disk.partitions.logical_volumes]]
name = "swaplv"
fs_type = "swap"
minsize = "1 GiB"
Copy to Clipboard Toggle word wrap

9.3.9. Packages installed by RHEL image builder

When you create a system image by using RHEL image builder, the system installs a set of base package groups.

Note

When you add additional components to your blueprint, ensure that the packages in the components you added do not conflict with any other package components. Otherwise, the system fails to solve dependencies and creating your customized image fails. You can check if there is no conflict between the packages by running the command:

# composer-cli blueprints depsolve BLUEPRINT-NAME
Copy to Clipboard Toggle word wrap

By default, RHEL image builder uses the Core group as the base list of packages.

Expand
Table 9.3. Default packages to support image type creation
Image typeDefault Packages

ami

checkpolicy, chrony, cloud-init, cloud-utils-growpart, @Core, dhcp-client, gdisk, insights-client, kernel, langpacks-en, net-tools, NetworkManager, redhat-release, redhat-release-eula, rng-tools, rsync, selinux-policy-targeted, tar, yum-utils

openstack

@core, langpacks-en

qcow2

@core, chrony, dnf, kernel, yum, nfs-utils, dnf-utils, cloud-init, python3-jsonschema, qemu-guest-agent, cloud-utils-growpart, dracut-norescue, tar, tcpdump, rsync, dnf-plugin-spacewalk, rhn-client-tools, rhnlib, rhnsd, rhn-setup, NetworkManager, dhcp-client, cockpit-ws, cockpit-system, subscription-manager-cockpit, redhat-release, redhat-release-eula, rng-tools, insights-client

tar

policycoreutils, selinux-policy-targeted

vhd

@core, langpacks-en

vmdk

@core, chrony, cloud-init, firewalld, langpacks-en, open-vm-tools, selinux-policy-targeted

edge-commit

redhat-release, glibc, glibc-minimal-langpack, nss-altfiles, dracut-config-generic, dracut-network, basesystem, bash, platform-python, shadow-utils, chrony, setup, shadow-utils, sudo, systemd, coreutils, util-linux, curl, vim-minimal, rpm, rpm-ostree, polkit, lvm2, cryptsetup, pinentry, e2fsprogs, dosfstools, keyutils, gnupg2, attr, xz, gzip, firewalld, iptables, NetworkManager, NetworkManager-wifi, NetworkManager-wwan, wpa_supplicant, traceroute, hostname, iproute, iputils, openssh-clients, procps-ng, rootfiles, openssh-server, passwd, policycoreutils, policycoreutils-python-utils, selinux-policy-targeted, setools-console, less, tar, rsync, usbguard, bash-completion, tmux, ima-evm-utils, audit, podman, containernetworking-plugins, container-selinux, skopeo, criu, slirp4netns, fuse-overlayfs, clevis, clevis-dracut, clevis-luks, greenboot, greenboot-default-health-checks, fdo-client, fdo-owner-cli, sos,

edge-container

dnf, dosfstools, e2fsprogs, glibc, lorax-templates-generic, lorax-templates-rhel, lvm2, policycoreutils, python36, python3-iniparse, qemu-img, selinux-policy-targeted, systemd, tar, xfsprogs, xz

edge-installer

aajohan-comfortaa-fonts, abattis-cantarell-fonts, alsa-firmware, alsa-tools-firmware, anaconda, anaconda-install-env-deps, anaconda-widgets, audit, bind-utils, bitmap-fangsongti-fonts, bzip2, cryptsetup, dbus-x11, dejavu-sans-fonts, dejavu-sans-mono-fonts, device-mapper-persistent-data, dnf, dump, ethtool, fcoe-utils, ftp, gdb-gdbserver, gdisk, gfs2-utils, glibc-all-langpacks, google-noto-sans-cjk-ttc-fonts, gsettings-desktop-schemas, hdparm, hexedit, initscripts, ipmitool, iwl3945-firmware, iwl4965-firmware, iwl6000g2a-firmware, iwl6000g2b-firmware, jomolhari-fonts, kacst-farsi-fonts, kacst-qurn-fonts, kbd, kbd-misc, kdump-anaconda-addon, khmeros-base-fonts, libblockdev-lvm-dbus, libertas-sd8686-firmware, libertas-sd8787-firmware, libertas-usb8388-firmware, libertas-usb8388-olpc-firmware, libibverbs, libreport-plugin-bugzilla, libreport-plugin-reportuploader, libreport-rhel-anaconda-bugzilla, librsvg2, linux-firmware, lklug-fonts, lldpad, lohit-assamese-fonts, lohit-bengali-fonts, lohit-devanagari-fonts, lohit-gujarati-fonts, lohit-gurmukhi-fonts, lohit-kannada-fonts, lohit-odia-fonts, lohit-tamil-fonts, lohit-telugu-fonts, lsof, madan-fonts, metacity, mtr, mt-st, net-tools, nmap-ncat, nm-connection-editor, nss-tools, openssh-server, oscap-anaconda-addon, pciutils, perl-interpreter, pigz, python3-pyatspi, rdma-core, redhat-release-eula, rpm-ostree, rsync, rsyslog, sg3_utils, sil-abyssinica-fonts, sil-padauk-fonts, sil-scheherazade-fonts, smartmontools, smc-meera-fonts, spice-vdagent, strace, system-storage-manager, thai-scalable-waree-fonts, tigervnc-server-minimal, tigervnc-server-module, udisks2, udisks2-iscsi, usbutils, vim-minimal, volume_key, wget, xfsdump, xorg-x11-drivers,xorg-x11-fonts-misc,xorg-x11-server-utils,xorg-x11-server-Xorg, xorg-x11-xauth

edge-simplified-installer

attr, basesystem, binutils, bsdtar, clevis-dracut, clevis-luks, cloud-utils-growpart, coreos-installer, coreos-installer-dracut, coreutils, device-mapper-multipath, dnsmasq, dosfstools, dracut-live, e2fsprogs, fcoe-utils, fdo-init, gzip, ima-evm-utils, iproute, iptables, iputils, iscsi-initiator-utils, keyutils, lldpad, lvm2, passwd, policycoreutils, policycoreutils-python-utils, procps-ng, rootfiles, setools-console, sudo, traceroute, util-linux

image-installer

aajohan-comfortaa-fonts, abattis-cantarell-fonts, alsa-firmware, alsa-tools-firmware, anaconda, anaconda-dracut, anaconda-install-env-deps, anaconda-widgets, audit, bind-utils, bitmap-fangsongti-fonts, bzip2, cryptsetup, curl, dbus-x11, dejavu-sans-fonts, dejavu-sans-mono-fonts, device-mapper-persistent-data, dmidecode, dnf, dracut-config-generic, dracut-network, efibootmgr, ethtool, fcoe-utils, ftp, gdb-gdbserver, gdisk, glibc-all-langpacks, gnome-kiosk, google-noto-sans-cjk-ttc-fonts, grub2-tools, grub2-tools-extra, grub2-tools-minimal, grubby, gsettings-desktop-schemas, hdparm, hexedit, hostname, initscripts, ipmitool, iwl1000-firmware, iwl100-firmware, iwl105-firmware, iwl135-firmware, iwl2000-firmware, iwl2030-firmware, iwl3160-firmware, iwl5000-firmware, iwl5150-firmware, iwl6000g2a-firmware, iwl6000g2b-firmware, iwl6050-firmware, iwl7260-firmware, jomolhari-fonts, kacst-farsi-fonts, kacst-qurn-fonts, kbd, kbd-misc, kdump-anaconda-addon, kernel, khmeros-base-fonts, less, libblockdev-lvm-dbus, libibverbs, libreport-plugin-bugzilla, libreport-plugin-reportuploader, librsvg2, linux-firmware, lklug-fonts, lldpad, lohit-assamese-fonts, lohit-bengali-fonts, lohit-devanagari-fonts, lohit-gujarati-fonts, lohit-gurmukhi-fonts, lohit-kannada-fonts, lohit-odia-fonts, lohit-tamil-fonts, lohit-telugu-fonts, lsof, madan-fonts, mtr, mt-st, net-tools, nfs-utils, nmap-ncat, nm-connection-editor, nss-tools, openssh-clients, openssh-server, oscap-anaconda-addon, ostree, pciutils, perl-interpreter, pigz, plymouth, prefixdevname, python3-pyatspi, rdma-core, redhat-release-eula, rng-tools, rpcbind, rpm-ostree, rsync, rsyslog, selinux-policy-targeted, sg3_utils, sil-abyssinica-fonts, sil-padauk-fonts, sil-scheherazade-fonts, smartmontools, smc-meera-fonts, spice-vdagent, strace, systemd, tar, thai-scalable-waree-fonts, tigervnc-server-minimal, tigervnc-server-module, udisks2,udisks2-iscsi,usbutils,vim-minimal, volume_key, wget, xfsdump, xfsprogs, xorg-x11-drivers, xorg-x11-fonts-misc, xorg-x11-server-utils, xorg-x11-server-Xorg, xorg-x11-xauth, xz,

edge-raw-image

dnf, dosfstools, e2fsprogs, glibc, lorax-templates-generic, lorax-templates-rhel, lvm2, policycoreutils, python36, python3-iniparse, qemu-img, selinux-policy-targeted, systemd, tar, xfsprogs, xz

gce

@core, langpacks-en, acpid, dhcp-client, dnf-automatic, net-tools, python3, rng-tools, tar, vim

9.3.10. Enabled services on custom images

When you use image builder to configure a custom image, the default services that the image uses are determined by the following:

  • The RHEL release on which you use the osbuild-composer utility
  • The image type

For example, the ami image type enables the sshd, chronyd, and cloud-init services by default. If these services are not enabled, the custom image does not boot.

Expand
Table 9.4. Enabled services to support image type creation
Image typeDefault enabled Services

ami

sshd, cloud-init, cloud-init-local, cloud-config, cloud-final

openstack

sshd, cloud-init, cloud-init-local, cloud-config, cloud-final

qcow2

cloud-init

rhel-edge-commit

No extra service enables by default

tar

No extra service enables by default

vhd

sshd, chronyd, waagent, cloud-init, cloud-init-local, cloud-config, cloud-final

vmdk

sshd, chronyd, vmtoolsd, cloud-init

Note: You can customize which services to enable during the system boot. However, the customization does not override services enabled by default for the mentioned image types.

RHEL image builder is a tool for creating custom system images. To control RHEL image builder and create your custom system images, you can use the web console interface.

With the cockpit-composer plugin for the RHEL web console, you can manage image builder blueprints and composes using a graphical interface.

Prerequisites

  • You must have root access to the system.
  • You installed RHEL image builder.
  • You installed the cockpit-composer package.

Procedure

  1. On the host, open https://<_localhost_>:9090/ in a web browser.
  2. Log in to the web console as the root user.
  3. To display the RHEL image builder controls, click the Image Builder button, in the upper-left corner of the window.

    The RHEL image builder dashboard opens, listing existing blueprints, if any.

Creating a blueprint is a necessary step before you build your customized RHEL system image. All the customizations available are optional. You can create a customized blueprint by using the following options:

Note

These blueprint customizations are available for Red Hat Enterprise Linux 9.2 or later versions and Red Hat Enterprise Linux 8.8 or later versions.

Prerequisites

Procedure

  1. Click Create Blueprint in the upper-right corner.

    A dialog wizard with fields for the blueprint name and description opens.

  2. On the Details page:

    1. Enter the name of the blueprint and, optionally, its description.
    2. Click Next.
  3. Optional: In the Packages page:

    1. On the Available packages search, enter the package name
    2. Click the > button to move it to the Chosen packages field.
    3. Repeat the previous steps to search and include as many packages as you want.
    4. Click Next.

      Note

      These customizations are all optional unless otherwise specified.

  4. On the Kernel page, enter a kernel name and the command-line arguments.
  5. On the File system page, you can select Use automatic partitioning or Manually configure partitions for your image file system. For manually configuring the partitions, complete the following steps:

    1. Click the Manually configure partitions button.

      The Configure partitions section opens, showing the configuration based on Red Hat standards and security guides.

    2. From the dropdown menu, provide details to configure the partitions:

      1. For the Mount point field, select one of the following mount point type options:

        • / - the root mount point
        • /app
        • /boot
        • /data
        • /home
        • /opt
        • /srv
        • /usr
        • /usr/local
        • /var

          You can also add an additional path to the Mount point, such as /tmp. For example: /var as a prefix and /tmp as an additional path results in /var/tmp.

          Note

          Depending on the Mount point type you choose, the file system type changes to xfs.

      2. For the Minimum size partition field of the file system, enter the needed minimum partition size. In the Minimum size dropdown menu, you can use common size units such as GiB, MiB, or KiB. The default unit is GiB.

        Note

        Minimum size means that RHEL image builder can still increase the partition sizes, in case they are too small to create a working image.

    3. To add more partitions, click the Add partition button. If you see the following error message: Duplicate partitions: Only one partition at each mount point can be created., you can:

      1. Click the Remove button to remove the duplicated partition.
      2. Choose a new mount point for the partition you want to create.
    4. After you finish the partitioning configuration, click Next.
  6. On the Services page, you can enable or disable services:

    1. Enter the service names you want to enable or disable, separating them by a comma, by space, or by pressing the Enter key. Click Next.
    2. Enter the Enabled services.
    3. Enter the Disabled services.
  7. On the Firewall page, set up your firewall setting:

    1. Enter the Ports, and the firewall services you want to enable or disable.
    2. Click the Add zone button to manage your firewall rules for each zone independently. Click Next.
  8. On the Users page, add a users by following the steps:

    1. Click Add user.
    2. Enter a Username, a Password, and a SSH key. You can also mark the user as a privileged user, by clicking the Server administrator checkbox. Click Next.
  9. On the Groups page, add groups by completing the following steps:

    1. Click the Add groups button:

      1. Enter a Group name and a Group ID. You can add more groups. Click Next.
  10. On the SSH keys page, add a key:

    1. Click the Add key button.

      1. Enter the SSH key.
      2. Enter a User. Click Next.
  11. On the Timezone page, set your time zone settings:

    1. On the Timezone field, enter the time zone you want to add to your system image. For example, add the following time zone format: "US/Eastern".

      If you do not set a time zone, the system uses Universal Time, Coordinated (UTC) as default.

    2. Enter the NTP servers. Click Next.
  12. On the Locale page, complete the following steps:

    1. On the Keyboard search field, enter the package name you want to add to your system image. For example: ["en_US.UTF-8"].
    2. On the Languages search field, enter the package name you want to add to your system image. For example: "us". Click Next.
  13. On the Others page, complete the following steps:

    1. On the Hostname field, enter the hostname you want to add to your system image. If you do not add a hostname, the operating system determines the hostname.
    2. Mandatory only for the Simplifier Installer image: On the Installation Devices field, enter a valid node for your system image. For example: dev/sda1. Click Next.
  14. Mandatory only when building images for FDO: On the FIDO device onboarding page, complete the following steps:

    1. On the Manufacturing server URL field, enter the following information:

      1. On the DIUN public key insecure field, enter the insecure public key.
      2. On the DIUN public key hash field, enter the public key hash.
      3. On the DIUN public key root certs field, enter the public key root certs. Click Next.
  15. On the OpenSCAP page, complete the following steps:

    1. On the Datastream field, enter the datastream remediation instructions you want to add to your system image.
    2. On the Profile ID field, enter the profile_id security profile you want to add to your system image. Click Next.
  16. Mandatory only when building images that use Ignition: On the Ignition page, complete the following steps:

    1. On the Firstboot URL field, enter the package name you want to add to your system image.
    2. On the Embedded Data field, drag or upload your file. Click Next.
  17. . On the Review page, review the details about the blueprint. Click Create.

The RHEL image builder view opens, listing existing blueprints.

You can import and use an already existing blueprint. The system automatically resolves all the dependencies.

Prerequisites

  • You have opened the RHEL image builder app from the web console in a browser.
  • You have a blueprint that you want to import to use in the RHEL image builder web console interface.

Procedure

  1. On the RHEL image builder dashboard, click Import blueprint. The Import blueprint wizard opens.
  2. From the Upload field, either drag or upload an existing blueprint. This blueprint can be in either TOML or JSON format.
  3. Click Import. The dashboard lists the blueprint you imported.

Verification

When you click the blueprint you imported, you have access to a dashboard with all the customizations for the blueprint that you imported.

  • To verify the packages that have been selected for the imported blueprint, navigate to the Packages tab.

    • To list all the package dependencies, click All. The list is searchable and can be ordered.

Next steps

  • Optional: To modify any customization:

    • From the Customizations dashboard, click the customization you want to make a change. Optionally, you can click Edit blueprint to navigate to all the available customization options.

You can export a blueprint to use the customizations in another system. You can export the blueprint in the TOML or in the JSON format. Both formats work on the CLI and also in the API interface.

Prerequisites

  • You have opened the RHEL image builder app from the web console in a browser.
  • You have a blueprint that you want to export.

Procedure

  1. On the image builder dashboard, select the blueprint you want to export.
  2. Click Export blueprint. The Export blueprint wizard opens.
  3. Click the Export button to download the blueprint as a file or click the Copy button to copy the blueprint to the clipboard.

    1. Optional: Click the Copy button to copy the blueprint.

Verification

  • Open the exported blueprint in a text editor to inspect and review it.

You can create a customized RHEL system image from a blueprint by completing the following steps.

Prerequisites

  • You opened the RHEL image builder app from the web console in a browser.
  • You created a blueprint.

Procedure

  1. In the RHEL image builder dashboard, click the blueprint tab.
  2. On the blueprint table, find the blueprint you want to build an image.
  3. On the right side of the chosen blueprint, click Create Image. The Create image dialog wizard opens.
  4. On the Image output page, complete the following steps:

    1. From the Select a blueprint list, select the image type you want.
    2. From the Image output type list, select the image output type you want.

      Depending on the image type you select, you need to add further details.

  5. Click Next.
  6. On the Review page, review the details about the image creation and click Create image.

    The image build starts and takes up to 20 minutes to complete.

Verification

After the image finishes building, you can:

  • Download the image.

    • On the RHEL image builder dashboard, click the Node options (⫶) menu and select Download image.
  • Download the logs of the image to inspect the elements and verify if any issue is found.

    • On the RHEL image builder dashboard, click the Node options (⫶) menu and select Download logs.

RHEL image builder can create custom system images ready for use on various cloud platforms. To use your customized RHEL system image in a cloud, create the system image with RHEL image builder by using the chosen output type, configure your system for uploading the image, and upload the image to your cloud account. You can push customized image clouds through the Image Builder application in the RHEL web console, available for a subset of the service providers that we support, such as AWS and Microsoft Azure clouds. See Creating and automatically uploading images directly to AWS Cloud AMI and Creating and automatically uploading VHD images directly to Microsoft Azure cloud.

9.5.1. Preparing and uploading AMI images to AWS

You can create custom images and can update them, either manually or automatically, to the AWS cloud with RHEL image builder.

Before uploading an AWS AMI image, you must configure a system for uploading the images.

Prerequisites

Procedure

  1. Install Python 3 and the pip tool:

    # yum install python3 python3-pip
    Copy to Clipboard Toggle word wrap
  2. Install the AWS command-line tools with pip:

    # pip3 install awscli
    Copy to Clipboard Toggle word wrap
  3. Set your profile. The terminal prompts you to provide your credentials, region and output format:

    $ aws configure
    AWS Access Key ID [None]:
    AWS Secret Access Key [None]:
    Default region name [None]:
    Default output format [None]:
    Copy to Clipboard Toggle word wrap
  4. Define a name for your bucket and create a bucket:

    $ BUCKET=bucketname
    $ aws s3 mb s3://$BUCKET
    Copy to Clipboard Toggle word wrap

    Replace bucketname with the actual bucket name. It must be a globally unique name. As a result, your bucket is created.

  5. To grant permission to access the S3 bucket, create a vmimport S3 Role in the AWS Identity and Access Management (IAM), if you have not already done so in the past:

    1. Create a trust-policy.json file with the trust policy configuration, in the JSON format. For example:

      {
          "Version": "2022-10-17",
          "Statement": [{
              "Effect": "Allow",
              "Principal": {
                  "Service": "vmie.amazonaws.com"
              },
              "Action": "sts:AssumeRole",
              "Condition": {
                  "StringEquals": {
                      "sts:Externalid": "vmimport"
                  }
              }
          }]
      }
      Copy to Clipboard Toggle word wrap
    2. Create a role-policy.json file with the role policy configuration, in the JSON format. For example:

      {
          "Version": "2012-10-17",
          "Statement": [{
              "Effect": "Allow",
              "Action": ["s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket"],
              "Resource": ["arn:aws:s3:::%s", "arn:aws:s3:::%s/"] }, { "Effect": "Allow", "Action": ["ec2:ModifySnapshotAttribute", "ec2:CopySnapshot", "ec2:RegisterImage", "ec2:Describe"],
              "Resource": "*"
          }]
      }
      $BUCKET $BUCKET
      Copy to Clipboard Toggle word wrap
    3. Create a role for your Amazon Web Services account, by using the trust-policy.json file:

      $ aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.json
      Copy to Clipboard Toggle word wrap
    4. Embed an inline policy document, by using the role-policy.json file:

      $ aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document file://role-policy.json
      Copy to Clipboard Toggle word wrap

You can use RHEL image builder to build ami images and manually upload them directly to Amazon AWS Cloud service provider, by using the CLI.

Prerequisites

  • You have an Access Key ID configured in the AWS IAM account manager.
  • You must have a writable S3 bucket prepared. See Creating S3 bucket.
  • You have a defined blueprint.

Procedure

  1. Using the text editor, create a configuration file with the following content:

    provider = "aws"
    [settings]
    accessKeyID = "AWS_ACCESS_KEY_ID"
    secretAccessKey = "AWS_SECRET_ACCESS_KEY"
    bucket = "AWS_BUCKET"
    region = "AWS_REGION"
    key = "IMAGE_KEY"
    Copy to Clipboard Toggle word wrap

    Replace values in the fields with your credentials for accessKeyID, secretAccessKey, bucket, and region. The IMAGE_KEY value is the name of your VM Image to be uploaded to EC2.

  2. Save the file as CONFIGURATION-FILE.toml and close the text editor.
  3. Start the compose to upload it to AWS:

    # composer-cli compose start blueprint-name image-type image-key configuration-file.toml
    Copy to Clipboard Toggle word wrap

    Replace:

    • blueprint-name with the name of the blueprint you created
    • image-type with the ami image type.
    • image-key with the name of your VM Image to be uploaded to EC2.
    • configuration-file.toml with the name of the configuration file of the cloud provider.

      Note

      You must have the correct AWS Identity and Access Management (IAM) settings for the bucket you are going to send your customized image to. You have to set up a policy to your bucket before you are able to upload images to it.

  4. Check the status of the image build:

    # composer-cli compose status
    Copy to Clipboard Toggle word wrap

    After the image upload process is complete, you can see the "FINISHED" status.

Verification

To confirm that the image upload was successful:

  1. Access EC2 on the menu and select the correct region in the AWS console. The image must have the available status, to indicate that it was successfully uploaded.
  2. On the dashboard, select your image and click Launch.

You can create a (.raw) image by using RHEL image builder, and choose to check the Upload to AWS checkbox to automatically push the output image that you create directly to the Amazon AWS Cloud AMI service provider.

Prerequisites

  • You must have root or wheel group user access to the system.
  • You have opened the RHEL image builder interface of the RHEL web console in a browser.
  • You have created a blueprint. See Creating a blueprint in the web console interface.
  • You must have an Access Key ID configured in the AWS IAM account manager.
  • You must have a writable S3 bucket prepared.

Procedure

  1. In the RHEL image builder dashboard, click the blueprint name that you previously created.
  2. Select the tab Images.
  3. Click Create Image to create your customized image.

    The Create Image window opens.

    1. From the Type drop-down menu list, select Amazon Machine Image Disk (.raw).
    2. Check the Upload to AWS checkbox to upload your image to the AWS Cloud and click Next.
    3. To authenticate your access to AWS, type your AWS access key ID and AWS secret access key in the corresponding fields. Click Next.

      Note

      You can view your AWS secret access key only when you create a new Access Key ID. If you do not know your Secret Key, generate a new Access Key ID.

    4. Type the name of the image in the Image name field, type the Amazon bucket name in the Amazon S3 bucket name field and type the AWS region field for the bucket you are going to add your customized image to. Click Next.
    5. Review the information and click Finish.

      Optionally, click Back to modify any incorrect detail.

      Note

      You must have the correct IAM settings for the bucket you are going to send your customized image. This procedure uses the IAM Import and Export, so you have to set up a policy to your bucket before you are able to upload images to it. For more information, see Required Permissions for IAM Users.

  4. A pop-up on the upper right informs you of the saving progress. It also informs that the image creation has been initiated, the progress of this image creation and the subsequent upload to the AWS Cloud.

    After the process is complete, you can see the Image build complete status.

  5. In a browser, access Service→EC2.

    1. On the AWS console dashboard menu, choose the correct region. The image must have the Available status, to indicate that it is uploaded.
    2. On the AWS dashboard, select your image and click Launch.
  6. A new window opens. Choose an instance type according to the resources you need to start your image. Click Review and Launch.
  7. Review your instance start details. You can edit each section if you need to make any changes. Click Launch
  8. Before you start the instance, select a public key to access it.

    You can either use the key pair you already have or you can create a new key pair.

    Follow the next steps to create a new key pair in EC2 and attach it to the new instance.

    1. From the drop-down menu list, select Create a new key pair.
    2. Enter the name to the new key pair. It generates a new key pair.
    3. Click Download Key Pair to save the new key pair on your local system.
  9. Then, you can click Launch Instance to start your instance.

    You can check the status of the instance, which displays as Initializing.

  10. After the instance status is running, the Connect button becomes available.
  11. Click Connect. A window appears with instructions on how to connect by using SSH.

    1. Select A standalone SSH client as the preferred connection method to and open a terminal.
    2. In the location you store your private key, ensure that your key is publicly viewable for SSH to work. To do so, run the command:

      $ chmod 400 <_your-instance-name.pem_>
      Copy to Clipboard Toggle word wrap
    3. Connect to your instance by using its Public DNS:

      $ ssh -i <_your-instance-name.pem_> ec2-user@<_your-instance-IP-address_>
      Copy to Clipboard Toggle word wrap
    4. Type yes to confirm that you want to continue connecting.

      As a result, you are connected to your instance over SSH.

Verification

  • Check if you are able to perform any action while connected to your instance by using SSH.

You can create custom images and can update them, either manually or automatically, to the Microsoft Azure cloud with RHEL image builder.

To create a VHD image that you can manually upload to Microsoft Azure cloud, you can use RHEL image builder.

Prerequisites

  • You must have a Microsoft Azure resource group and storage account.
  • You have Python installed. The AZ CLI tool depends on python.

Procedure

  1. Import the Microsoft repository key:

    # rpm --import https://packages.microsoft.com/keys/microsoft.asc
    Copy to Clipboard Toggle word wrap
  2. Create a local azure-cli.repo repository with the following information. Save the azure-cli.repo repository under /etc/yum.repos.d/:

    [azure-cli]
    name=Azure CLI
    baseurl=https://packages.microsoft.com/yumrepos/vscode
    enabled=1
    gpgcheck=1
    gpgkey=https://packages.microsoft.com/keys/microsoft.asc
    Copy to Clipboard Toggle word wrap
  3. Install the Microsoft Azure CLI:

    # yumdownloader azure-cli
    # rpm -ivh --nodeps azure-cli-2.0.64-1.el7.x86_64.rpm
    Copy to Clipboard Toggle word wrap
    Note

    The downloaded version of the Microsoft Azure CLI package can vary depending on the current available version.

  4. Run the Microsoft Azure CLI:

    $ az login
    Copy to Clipboard Toggle word wrap

    The terminal shows the following message Note, we have launched a browser for you to login. For old experience with device code, use "az login --use-device-code. Then, the terminal opens a browser with a link to https://microsoft.com/devicelogin from where you can login.

    Note

    If you are running a remote (SSH) session, the login page link will not open in the browser. In this case, you can copy the link to a browser and login to authenticate your remote session. To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the device code to authenticate.

  5. List the keys for the storage account in Microsoft Azure:

    $ az storage account keys list --resource-group <resource_group_name> --account-name <storage_account_name>
    Copy to Clipboard Toggle word wrap

    Replace resource-group-name with name of your Microsoft Azure resource group and storage-account-name with name of your Microsoft Azure storage account.

    Note

    You can list the available resources using the following command:

    $ az resource list
    Copy to Clipboard Toggle word wrap

    Make note of value key1 in the output of the previous command.

  6. Create a storage container:

    $ az storage container create --account-name <storage_account_name>\
    --account-key <key1_value> --name <storage_account_name>
    Copy to Clipboard Toggle word wrap

    Replace storage-account-name with name of the storage account.

After you have created your customized VHD image, you can manually upload it to the Microsoft Azure cloud.

Prerequisites

  • Your system must be set up for uploading Microsoft Azure VHD images. See Preparing to upload Microsoft Azure VHD images.
  • You must have a Microsoft Azure VHD image created by RHEL image builder.

    • In the GUI, use the Azure Disk Image (.vhd) image type.
    • In the CLI, use the vhd output type.

Procedure

  1. Push the image to Microsoft Azure and create an instance from it:

    $ az storage blob upload --account-name <_account_name_> --container-name <_container_name_> --file <_image_-disk.vhd> --name <_image_-disk.vhd> --type page
    ...
    Copy to Clipboard Toggle word wrap
  2. After the upload to the Microsoft Azure Blob storage completes, create a Microsoft Azure image from it:

    $ az image create --resource-group <_resource_group_name_> --name <_image_>-disk.vhd --os-type linux --location <_location_> --source https://$<_account_name_>.blob.core.windows.net/<_container_name_>/<_image_>-disk.vhd
     - Running ...
    Copy to Clipboard Toggle word wrap
    Note

    Because the images that you create with RHEL image builder generate hybrid images that support to both the V1 = BIOS and V2 = UEFI instances types, you can specify the --hyper-v-generation argument. The default instance type is V1.

Verification

  1. Create an instance either with the Microsoft Azure portal, or a command similar to the following:

    $ az vm create --resource-group <_resource_group_name_> --location <_location_> --name <_vm_name_> --image <_image_>-disk.vhd --admin-username azure-user --generate-ssh-keys
     - Running ...
    Copy to Clipboard Toggle word wrap
  2. Use your private key via SSH to access the resulting instance. Log in as azure-user. This username was set on the previous step.

You can create .vhd images by using RHEL image builder that will be automatically uploaded to a Blob Storage of the Microsoft Azure Cloud service provider.

Prerequisites

Procedure

  1. In the RHEL image builder dashboard, select the blueprint you want to use.
  2. Click the Images tab.
  3. Click Create Image to create your customized .vhd image.

    The Create image wizard opens.

    1. Select Microsoft Azure (.vhd) from the Type drop-down menu list.
    2. Check the Upload to Azure checkbox to upload your image to the Microsoft Azure Cloud.
    3. Enter the Image Size and click Next.
  4. On the Upload to Azure page, enter the following information:

    1. On the Authentication page, enter:

      1. Your Storage account name. You can find it on the Storage account page, in the Microsoft Azure portal.
      2. Your Storage access key: You can find it on the Access Key Storage page.
      3. Click Next.
    2. On the Authentication page, enter:

      1. The image name.
      2. The Storage container. It is the blob container to which you will upload the image. Find it under the Blob service section, in the Microsoft Azure portal.
      3. Click Next.
  5. On the Review page, click Create. The RHEL image builder and upload processes start.

    Access the image you pushed into Microsoft Azure Cloud.

  6. Access the Microsoft Azure portal.
  7. In the search bar, type "storage account" and click Storage accounts from the list.
  8. On the search bar, type "Images" and select the first entry under Services. You are redirected to the Image dashboard.
  9. On the navigation panel, click Containers.
  10. Find the container you created. Inside the container is the .vhd file you created and pushed by using RHEL image builder.

Verification

  1. Verify that you can create a VM image and launch it.

    1. In the search bar, type images account and click Images from the list.
    2. Click +Create.
    3. From the dropdown list, choose the resource group you used earlier.
    4. Enter a name for the image.
    5. For the OS type, select Linux.
    6. For the VM generation, select Gen 2.
    7. Under Storage Blob, click Browse and click through the storage accounts and container until you reach your VHD file.
    8. Click Select at the end of the page.
    9. Choose an Account Type, for example, Standard SSD.
    10. Click Review + Create and then Create. Wait a few moments for the image creation.
  2. To launch the VM, follow the steps:

    1. Click Go to resource.
    2. Click + Create VM from the menu bar on the header.
    3. Enter a name for your virtual machine.
    4. Complete the Size and Administrator account sections.
    5. Click Review + Create and then Create. You can see the deployment progress.

      After the deployment finishes, click the virtual machine name to retrieve the public IP address of the instance to connect by using SSH.

    6. Open a terminal to create an SSH connection to connect to the VM.

With RHEL image builder, you can create customized VMware vSphere system images, either in the Open virtualization format (.ova) or in the Virtual disk (.vmdk) format. You can upload these images to the VMware vSphere client. You can upload the .vmdk or .ova image to VMware vSphere using the govc import.vmdk CLI tool. The vmdk you create contains the cloud-init package installed and you can use it to provision users by using user data, for example.

Note

Uploading vmdk images by using the VMware vSphere GUI is not supported.

Prerequisites

  • You created a blueprint with username and password customizations.
  • You created a VMware vSphere image either in the .ova or .vmdk format by using RHEL image builder and downloaded it to your host system.
  • You installed and configured the govc CLI tool, to be able use the import.vmdk command.

Procedure

  1. Configure the following values in the user environment with the GOVC environment variables:

    GOVC_URL
    GOVC_DATACENTER
    GOVC_FOLDER
    GOVC_DATASTORE
    GOVC_RESOURCE_POOL
    GOVC_NETWORK
    Copy to Clipboard Toggle word wrap
  2. Navigate to the directory where you downloaded your VMware vSphere image.
  3. Launch the VMware vSphere image on vSphere by following the steps:

    1. Import the VMware vSphere image in to vSphere:

      $ govc import.vmdk ./composer-api.vmdk foldername
      Copy to Clipboard Toggle word wrap

      For the .ova format:

      $ govc import.ova ./composer-api.ova foldername
      Copy to Clipboard Toggle word wrap
    2. Create the VM in vSphere without powering it on:

      govc vm.create \
      -net.adapter=vmxnet3 \
      -m=4096 -c=2 -g=rhel8_64Guest \
      -firmware=efi -disk=”foldername/composer-api.vmdk” \
      -disk.controller=scsi -on=false \
       vmname
      Copy to Clipboard Toggle word wrap

      For the .ova format, replace the line -firmware=efi -disk=”foldername/composer-api.vmdk” \ with `-firmware=efi -disk=”foldername/composer-api.ova” \

    3. Power-on the VM:

      govc vm.power -on vmname
      Copy to Clipboard Toggle word wrap
    4. Retrieve the VM IP address:

      govc vm.ip vmname
      Copy to Clipboard Toggle word wrap
    5. Use SSH to log in to the VM, using the username and password you specified in your blueprint:

      $ ssh admin@<_ip_address_of_the_vm_>
      Copy to Clipboard Toggle word wrap
      Note

      If you copied the .vmdk image from your local host to the destination using the govc datastore.upload command, using the resulting image is not supported. There is no option to use the import.vmdk command in the vSphere GUI and as a result, the vSphere GUI does not support the direct upload. As a consequence, the .vmdk image is not usable from the vSphere GUI.

You can build VMware images by using the RHEL image builder GUI tool and automatically push the images directly to your vSphere instance. This avoids the need to download the image file and push it manually. The vmdk you create contains the cloud-init package installed and you can use it to provision users by using user data, for example. To build .vmdk images by using RHEL image builder and push them directly to vSphere instances service provider, follow the steps:

Prerequisites

Procedure

  1. For the blueprint you created, click the Images tab .
  2. Click Create Image to create your customized image.

    The Image type window opens.

  3. In the Image type window:

    1. From the dropdown menu, select the Type: VMware vSphere (.vmdk).
    2. Check the Upload to VMware checkbox to upload your image to the vSphere.
    3. Optional: Set the size of the image you want to instantiate. The minimal default size is 2 GB.
    4. Click Next.
  4. In the Upload to VMware window, under Authentication, enter the following details:

    1. Username: username of the vSphere account.
    2. Password: password of the vSphere account.
  5. In the Upload to VMware window, under Destination, enter the following details about the image upload destination:

    1. Image name: a name for the image.
    2. Host: The URL of your VMware vSphere.
    3. Cluster: The name of the cluster.
    4. Data center: The name of the data center.
    5. Data store:The name of the Data store.
    6. Click Next.
  6. In the Review window, review the details of the image creation and click Finish.

    You can click Back to modify any incorrect detail.

    RHEL image builder adds the compose of a RHEL vSphere image to the queue, and creates and uploads the image to the Cluster on the vSphere instance you specified.

    Note

    The image build and upload processes take a few minutes to complete.

    After the process is complete, you can see the Image build complete status.

Verification

After the image status upload is completed successfully, you can create a Virtual Machine (VM) from the image you uploaded and login into it. To do so:

  1. Access VMware vSphere Client.
  2. Search for the image in the Cluster on the vSphere instance you specified.
  3. Select the image you uploaded.
  4. Right-click the selected image.
  5. Click New Virtual Machine.

    A New Virtual Machine window opens.

    In the New Virtual Machine window, provide the following details:

    1. Select New Virtual Machine.
    2. Select a name and a folder for your VM.
    3. Select a computer resource: choose a destination computer resource for this operation.
    4. Select storage: For example, select NFS-Node1
    5. Select compatibility: The image should be BIOS only.
    6. Select a guest operating system: For example, select Linux and Red Hat Fedora (64-bit).
    7. Customize hardware: When creating a VM, on the Device Configuration button on the upper right, delete the default New Hard Disk and use the drop-down to select an Existing Hard Disk disk image:
    8. Ready to complete: Review the details and click Finish to create the image.
  6. Navigate to the VMs tab.

    1. From the list, select the VM you created.
    2. Click the Start button from the panel. A new window appears, showing the VM image loading.
    3. Log in with the credentials you created for the blueprint.
    4. You can verify if the packages you added to the blueprint are installed. For example:

      $ rpm -qa | grep firefox
      Copy to Clipboard Toggle word wrap

You can create custom images and then automatically update them to the Oracle Cloud Infrastructure (OCI) instance with RHEL image builder.

With RHEL image builder, you can build a gce image, provide credentials for your user or GCP service account, and then upload the gce image directly to the GCP environment.

Set up a configuration file with credentials to upload your gce image to GCP by using the RHEL image builder CLI.

Warning

You cannot manually import gce image to GCP, because the image will not boot. You must use either gcloud or RHEL image builder to upload it.

Prerequisites

  • You have a valid Google account and credentials to upload your image to GCP. The credentials can be from a user account or a service account. The account associated with the credentials must have at least the following IAM roles assigned:

    • roles/storage.admin - to create and delete storage objects
    • roles/compute.storageAdmin - to import a VM image to Compute Engine.
  • You have an existing GCP bucket.

Procedure

  1. Use a text editor to create a gcp-config.toml configuration file with the following content:

    provider = "gcp"
    [settings]
    bucket = "GCP_BUCKET"
    region = "GCP_STORAGE_REGION"
    object = "OBJECT_KEY"
    credentials = "GCP_CREDENTIALS"
    Copy to Clipboard Toggle word wrap
    • GCP_BUCKET points to an existing bucket. It is used to store the intermediate storage object of the image which is being uploaded.
    • GCP_STORAGE_REGION is both a regular Google storage region and a dual or multi region.
    • OBJECT_KEY is the name of an intermediate storage object. It must not exist before the upload, and it is deleted when the upload process is done. If the object name does not end with .tar.gz, the extension is automatically added to the object name.
    • GCP_CREDENTIALS is a Base64-encoded scheme of the credentials JSON file downloaded from GCP. The credentials determine which project the GCP uploads the image to.

      Note

      Specifying GCP_CREDENTIALS in the gcp-config.toml file is optional if you use a different mechanism to authenticate with GCP. For other authentication methods, see Authenticating with GCP.

  2. Retrieve the GCP_CREDENTIALS from the JSON file downloaded from GCP.

    $ sudo base64 -w 0 cee-gcp-nasa-476a1fa485b7.json
    Copy to Clipboard Toggle word wrap
  3. Create a compose with an additional image name and cloud provider profile:

    $ sudo composer-cli compose start BLUEPRINT-NAME gce IMAGE_KEY gcp-config.toml
    Copy to Clipboard Toggle word wrap

    The image build, upload, and cloud registration processes can take up to ten minutes to complete.

Verification

  • Verify that the image status is FINISHED:

    $ sudo composer-cli compose status
    Copy to Clipboard Toggle word wrap

You can use several different types of credentials with RHEL image builder to authenticate with GCP. If RHEL image builder configuration is set to authenticate with GCP using multiple sets of credentials, it uses the credentials in the following order of preference:

  1. Credentials specified with the composer-cli command in the configuration file.
  2. Credentials configured in the osbuild-composer worker configuration.
  3. Application Default Credentials from the Google GCP SDK library, which tries to automatically find a way to authenticate by using the following options:

    1. If the GOOGLE_APPLICATION_CREDENTIALS environment variable is set, Application Default Credentials tries to load and use credentials from the file pointed to by the variable.
    2. Application Default Credentials tries to authenticate by using the service account attached to the resource that is running the code. For example, Google Compute Engine VM.

      Note

      You must use the GCP credentials to determine which GCP project to upload the image to. Therefore, unless you want to upload all of your images to the same GCP project, you always must specify the credentials in the gcp-config.toml configuration file with the composer-cli command.

You can specify GCP authentication credentials in the upload target configuration gcp-config.toml file. Use a Base64-encoded scheme of the Google account credentials JSON file to save time.

Procedure

  1. Get the encoded content of the Google account credentials file with the path stored in GOOGLE_APPLICATION_CREDENTIALS environment variable, by running the following command:

    $ base64 -w 0 "${GOOGLE_APPLICATION_CREDENTIALS}"
    Copy to Clipboard Toggle word wrap
  2. In the upload target configuration gcp-config.toml file, set the credentials:

    provider = "gcp"
    
    [settings]
    provider = "gcp"
    
    [settings]
    credentials = "GCP_CREDENTIALS"
    Copy to Clipboard Toggle word wrap

You can configure GCP authentication credentials to be used for GCP globally for all image builds. This way, if you want to import images to the same GCP project, you can use the same credentials for all image uploads to GCP.

Procedure

  • In the /etc/osbuild-worker/osbuild-worker.toml worker configuration, set the following credential value:

    [gcp]
    credentials = "PATH_TO_GCP_ACCOUNT_CREDENTIALS"
    Copy to Clipboard Toggle word wrap

You can create custom images and then automatically update them to the Oracle Cloud Infrastructure (OCI) instance with RHEL image builder.

With RHEL image builder, build customized images and automatically push them directly to your Oracle Cloud Infrastructure (OCI) instance. Then, you can start an image instance from the OCI dashboard.

Prerequisites

  • You have root or weldr group user access to the system.
  • You have an Oracle Cloud account.
  • You must be granted security access in an OCI policy by your administrator.
  • You have created an OCI Bucket in the OCI_REGION of your choice.

Procedure

  1. Open the RHEL image builder interface of the web console in a browser.
  2. Click Create blueprint. The Create blueprint wizard opens.
  3. On the Details page, enter a name for the blueprint, and optionally, a description. Click Next.
  4. On the Packages page, select the components and packages that you want to include in the image. Click Next.
  5. On the Customizations page, configure the customizations that you want for your blueprint. Click Next.
  6. On the Review page, click Create.
  7. To create an image, click Create Image. The Create image wizard opens.
  8. On the Image output page, complete the following steps:

    1. From the "Select a blueprint" drop-down menu, select the blueprint you want.
    2. From the "Image output type" drop-down menu, select Oracle Cloud Infrastructure (.qcow2).
    3. Check the "Upload OCI checkbox to upload your image to the OCI.
    4. Enter the "image size". Click Next.
  9. On the Upload to OCI - Authentication page, enter the following mandatory details:

    1. User OCID: you can find it in the Console on the page showing the user’s details.
    2. Private key
  10. On the Upload to OCI - Destination page, enter the following mandatory details and click Next.

    1. Image name: a name for the image to be uploaded.
    2. OCI bucket
    3. Bucket namespace
    4. Bucket region
    5. Bucket compartment
    6. Bucket tenancy
  11. Review the details in the wizard and click Finish.

RHEL image builder adds the compose of a RHEL .qcow2 image to the queue.

Verification

  1. Access the OCI dashboard Custom Images.
  2. Select the Compartment you specified for the image and locate the image in the Import image table.
  3. Click the image name and verify the image information.

You can create custom .qcow2 images with RHEL image builder, and manually upload them to the OpenStack cloud deployments.

9.5.5.1. Uploading QCOW2 images to OpenStack

With the RHEL image builder tool, you can create customized .qcow2 images that are suitable for uploading to OpenStack cloud deployments, and starting instances there. RHEL image builder creates images in the QCOW2 format, but with further changes specific to OpenStack.

Warning

Do not mistake the generic QCOW2 image type output format you create by using RHEL image builder with the OpenStack image type, which is also in the QCOW2 format, but contains further changes specific to OpenStack.

Prerequisites

  • You have created a blueprint.

Procedure

  1. Start the compose of a QCOW2 image.

    # composer-cli compose start blueprint_name openstack
    Copy to Clipboard Toggle word wrap
  2. Check the status of the building.

    # composer-cli compose status
    Copy to Clipboard Toggle word wrap

    After the image build finishes, you can download the image.

  3. Download the QCOW2 image:

    # composer-cli compose image UUID
    Copy to Clipboard Toggle word wrap
  4. Access the OpenStack dashboard and click +Create Image.
  5. On the left menu, select the Admin tab.
  6. From the System Panel, click Image.

    The Create An Image wizard opens.

  7. In the Create An Image wizard:

    1. Enter a name for the image
    2. Click Browse to upload the QCOW2 image.
    3. From the Format dropdown list, select the QCOW2 - QEMU Emulator.
    4. Click Create Image.

      composer openstack upload image

  8. On the left menu, select the Project tab.

    1. From the Compute menu, select Instances.
    2. Click the Launch Instance button.

      The Launch Instance wizard opens.

    3. On the Details page, enter a name for the instance. Click Next.
    4. On the Source page, select the name of the image you uploaded. Click Next.
    5. On the Flavor page, select the machine resources that best fit your needs. Click Launch.

      composer openstack start instance

  9. You can run the image instance using any mechanism (CLI or OpenStack web UI) from the image. Use your private key via SSH to access the resulting instance. Log in as cloud-user.

You can upload a customized .ami images that you created by using RHEL image builder to the Alibaba Cloud.

To deploy a customized RHEL image to the Alibaba Cloud, first you need to verify the customized image. The image needs a specific configuration to boot successfully, because Alibaba Cloud requests the custom images to meet certain requirements before you use it.

Note

RHEL image builder generates images that conform to Alibaba’s requirements. However, Red Hat recommends also using the Alibaba image_check tool to verify the format compliance of your image.

Prerequisites

  • You must have created an Alibaba image by using RHEL image builder.

Procedure

  1. Connect to the system containing the image that you want to check by using the Alibaba image_check tool.
  2. Download the image_check tool:

    $ curl -O https://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/73848/cn_zh/1557459863884/image_check
    Copy to Clipboard Toggle word wrap
  3. Change the file permission of the image compliance tool:

    # chmod +x image_check
    Copy to Clipboard Toggle word wrap
  4. Run the command to start the image compliance tool checkup:

    # ./image_check
    Copy to Clipboard Toggle word wrap

    The tool verifies the system configuration and generates a report that is displayed on your screen. The image_check tool saves this report in the same folder where the image compliance tool is running.

Troubleshooting

If any of the Detection Items fail, follow the instructions in the terminal to correct it.

You can upload a customized AMI image you created by using RHEL image builder to the Object Storage Service (OSS).

Prerequisites

Procedure

  1. Log in to the OSS console.
  2. In the Bucket menu on the left, select the bucket to which you want to upload an image.
  3. In the upper right menu, click the Files tab.
  4. Click Upload. A dialog window opens on the right side. Configure the following:

    • Upload To: Choose to upload the file to the Current directory or to a Specified directory.
    • File ACL: Choose the type of permission of the uploaded file.
  5. Click Upload.
  6. Select the image you want to upload to the OSS Console..
  7. Click Open.

9.5.6.3. Importing images to Alibaba Cloud

To import a customized Alibaba RHEL image that you created by using RHEL image builder to the Elastic Compute Service (ECS), follow the steps:

Prerequisites

Procedure

  1. Log in to the ECS console.

    1. On the left-side menu, click Images.
    2. On the upper right side, click Import Image. A dialog window opens.
    3. Confirm that you have set up the correct region where the image is located. Enter the following information:

      1. OSS Object Address: See how to obtain OSS Object Address.
      2. Image Name
      3. Operating System
      4. System Disk Size
      5. System Architecture
      6. Platform: Red Hat
    4. Optional: Provide the following details:

      1. Image Format: qcow2 or ami, depending on the uploaded image format.
      2. Image Description
      3. Add Images of Data Disks

        The address can be determined in the OSS management console. After selecting the required bucket in the left menu:

  2. Select Files section.
  3. Click the Details link on the right for the appropriate image.

    A window appears on the right side of the screen, showing image details. The OSS object address is in the URL box.

  4. Click OK.

    Note

    The importing process time can vary depending on the image size.

The customized image is imported to the ECS Console.

You can create instances of a customized RHEL image by using the Alibaba ECS Console.

Prerequisites

Procedure

  1. Log in to the ECS console.
  2. On the left-side menu, select Instances.
  3. In the upper-right corner, click Create Instance. You are redirected to a new window.
  4. Complete all the required information. See Creating an instance by using the wizard for more details.
  5. Click Create Instance and confirm the order.

    Note

    You can see the option Create Order instead of Create Instance, depending on your subscription.

As a result, you have an active instance ready for deployment from the Alibaba ECS Console.

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat