Composing a customized RHEL system image
Creating customized system images with RHEL image builder on RHEL 10.0
Abstract
Providing feedback on Red Hat documentation Copy linkLink copied to clipboard!
We are committed to providing high-quality documentation and value your feedback. To help us improve, you can submit suggestions or report errors through the Red Hat Jira tracking system.
Procedure
Log in to the Jira website.
If you do not have an account, select the option to create one.
- Click Create in the top navigation bar.
- Enter a descriptive title in the Summary field.
- Enter your suggestion for improvement in the Description field. Include links to the relevant parts of the documentation.
- Click Create at the bottom of the window.
Chapter 1. RHEL image builder description Copy linkLink copied to clipboard!
You can use RHEL image builder to create customized RHEL system images, including images for deployment on cloud platforms. By using RHEL image builder, you can automatically handle setup details for each output type, making it easier and faster than manual image creation. You can access RHEL image builder by using the image-builder CLI tool or the graphical user interface in the RHEL web console.
The image-builder tool, available as a Technology Preview, has the following characteristics:
- A simpler installation and environment configuration.
- You can work with a container-friendly daemonless model, removing the complexity of a client/server architecture.
-
You can use
image-builderfor automated pipelines and container-based builds. -
image-buildersupports creating a container image that you can use as a portable environment to build other images.
1.1. RHEL image builder terminology Copy linkLink copied to clipboard!
RHEL image builder uses specific terminology for its core 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.
1.2. RHEL image builder output formats Copy linkLink copied to clipboard!
RHEL image builder can create images in multiple output formats shown in the table.
| Description | CLI name | File extension | Architecture |
|---|---|---|---|
| Amazon Web Services |
|
|
|
| Disk Archive |
|
|
|
| Google Cloud |
|
|
|
| Microsoft Azure |
|
|
|
| OpenStack |
|
|
|
| Oracle Cloud Infrastructure |
|
|
|
| QEMU Image |
|
|
|
| RHEL Installer |
|
|
|
| VMware vSphere |
|
|
|
| VMware vSphere |
|
|
|
| Vagrant |
|
|
|
| Windows Subsystem for Linux |
|
|
|
To check the supported types, run the command:
# image-builder list
1.3. Supported architectures for image builds Copy linkLink copied to clipboard!
RHEL image builder supports building images for several architectures.
The supported architectures include:
-
AMD and Intel 64-bit (
x86_64) -
ARM64 (
aarch64) -
IBM Z (
s390x) -
IBM POWER systems (
ppc64)
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.
Chapter 2. Installing RHEL image builder Copy linkLink copied to clipboard!
RHEL image builder is a tool for creating custom system images. Before using RHEL image builder, you must install it.
2.1. RHEL image builder system requirements Copy linkLink copied to clipboard!
The host that runs RHEL image builder must meet the minimum system requirements.
| Parameter | Minimal Required Value |
|---|---|
| System type | A dedicated host or virtual machine. 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 |
| Access privileges | root |
| Network | Internet connectivity to the Red Hat Content Delivery Network (CDN). |
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.
2.2. Installing RHEL image builder Copy linkLink copied to clipboard!
Install RHEL image builder to have access to all the image-builder packages functionalities.
Prerequisites
- You are logged in to the Red Hat Enterprise Linux host on which you want to install RHEL image builder.
- The Red Hat Enterprise Linux host is subscribed to Red Hat Subscription Manager (RHSM) or Red Hat Satellite.
-
You have enabled the
BaseOSandAppStreamrepositories to be able to install the RHEL image builder packages.
Procedure
Install RHEL image builder and other necessary packages:
# dnf install image-builder cockpit-image-builder-
image-builderis a service to build customized RHEL operating system images and enables access to the CLI interface. -
cockpit-image-builderis a package that enables access to the Web UI interface. The web console is installed as a dependency of thecockpit-image-builderpackage.
-
If you want to use RHEL image builder in the web console, enable and start it.
# systemctl enable --now cockpit.socketThe
image-builderandcockpitservices start automatically on first access.
Verification
Verify that the installation works by running
image-builder:# image-builder list
Chapter 3. Configuring RHEL image builder repositories Copy linkLink copied to clipboard!
You can add repositories or override the default base repositories.
You can use the following types of repositories in RHEL image builder:
- Official repository overrides
- Use these to download base system RPMs from a custom mirror, instead of the Red Hat Content Delivery Network (CDN). Official repositories overrides disables the default repositories, and your custom mirror must contain all the necessary packages.
- Custom third-party repositories
- Use these to include packages that are not available in the official RHEL repositories.
3.1. Adding additional repositories to RHEL image builder Copy linkLink copied to clipboard!
You can add additional custom repositories to your image during the image-building time by using the image-builder tool and the --extra-repo flag.
Prerequisites
- You have the URL of the custom repository.
Procedure
Build the image, and add the extra repository to RHEL image builder:
$ image-builder build <image-type> \ --extra-repo=<file:///path/to/my/repo> \The repository content becomes available during the image building, and the dependency solver gets packages from the repository. For example, if the repository contains a
libcorkernelwith higher version, their content is selected over the default repositories.
3.2. Adding third-party repositories with specific distributions to RHEL image builder Copy linkLink copied to clipboard!
You can add custom repositories and specify a distribution to your image by using the image-builder tool and with --extra-repo flag.
Prerequisites
- You have the custom repository URL.
Procedure
Build the image, and add the extra repository source and the chosen distribution system to RHEL image builder:
$ image-builder build <image-type> \ --extra-repo <file:///path/to/my/repo> \ --distro rhel-10.0 \
3.3. Overriding a system repository during image build Copy linkLink copied to clipboard!
Override the default base repositories during image build.
Prerequisites
- You have a custom repository that is accessible from your host system.
Procedure
Build the image, and add the extra repository to RHEL image builder:
$ image-builder build <image-type> \ --force-repo=<file:///path/to/my/repo> \WarningThe RHEL image builder tool uses the repositories that you defined to solve all dependencies, which could cause issues for your system.
3.4. Configuring and using Satellite CV as a content source Copy linkLink copied to clipboard!
You can use Satellite’s content views (CV) as repositories to build images with RHEL image builder. Configure your Satellite-registered hosts to use Satellite repositories instead of the Red Hat Content Delivery Network (CDN).
Prerequisites
- You have installed RHEL image builder. See Installing RHEL image builder.
- You are using RHEL image builder on a host registered to Satellite 6. See Using a RHEL image builder image for Provisioning.
Procedure
Find the repository URL from your currently configured Satellite repositories:
The following output is an example:
https://satellite6.example.com/pulp/content/<your_org>/<your_env>/<your_cv>/content/dist/rhel10/10/x86_64/baseos/osBuild the image, and add the Satellite repository to RHEL image builder:
$ image-builder build <image-type> \ --add-repo=<file:///path/to/satellite/repo> \
3.5. Using Satellite CV as repositories to build images in RHEL image builder Copy linkLink copied to clipboard!
Configure RHEL image builder to use Satellite’s content views (CV) as repositories to build your custom images.
Prerequisites
- You have integrated Satellite with RHEL web console. See Enabling the RHEL web console on Satellite
Procedure
- In the Satellite web UI, navigate to Content, locate Products, select your Product, and click the repository you want to use.
-
Search for the secured URL (HTTPS) in the
Publishedfield and copy it. - Use the URL that you copied as a base URL for the Red Hat image builder repository. See Adding custom third-party repositories to RHEL image builder.
Chapter 4. Creating system images by using the RHEL image builder CLI Copy linkLink copied to clipboard!
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.
4.1. Introducing the RHEL image builder command-line interface Copy linkLink copied to clipboard!
You can use the RHEL image builder command-line interface (CLI) to create blueprints, by running the image-builder command with the suitable options and subcommands.
By default, you must run the image-builder command as a root user.
The workflow for the command line can be summarized as follows:
- Create a blueprint or export an existing blueprint definition to a plain text file.
- Optional: Edit this file in a text editor.
- Import the blueprint text file back into image builder.
- Run a compose to build an image from the blueprint.
- Export the image file to download it.
Apart from the basic subcommands to create a blueprint, you can use the image-builder command with many subcommands to examine the state of configured blueprints and composes.
4.2. RHEL image builder blueprint format Copy linkLink copied to clipboard!
With RHEL image builder, you can use blueprints in both the .toml and .json formats.
A typical blueprint file includes the following elements:
- The blueprint metadata
name = "<blueprint_name>" description = "<long_form_description_text>" version = "<version>"The
<blueprint_name>and<long_form_description_text>fields are the 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>"The
<group_name>entry describes a group of packages to be installed into the image. Groups use the following package categories:- Mandatory
- Default
Optional
The
group-nameis 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>"package-nameis the name of the package, such ashttpd,gdb-doc, orcoreutils.package-versionis a version to use. In this field, you can specify dnfversion constraints as follows:-
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 a format such as
8.*.Repeat this block for every package to include.
NoteThere are no differences between packages and modules in the RHEL image builder tool. RHEL image builder treatd both as RPM Package Manager (RPM) package dependencies.
-
For a specific version, use the exact version number, such as
4.3. Creating a blueprint by using the command line Copy linkLink copied to clipboard!
You can create a new blueprint by using the command line (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
weldrgroup
Procedure
Create a plain text file with the following contents:
name = "<blueprint_name>" description = "<long_form_description>" version = "<0.0.1>" modules = [] groups = []Replace
<blueprint_name>and<long_form_description>with a name and description for your blueprint.Replace
<0.0.1>with a version number according to the Semantic Versioning scheme.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>"Replace
<package_name>with the name of the package, such ashttpd,gdb-doc, orcoreutils.Optionally, replace
<package_version>with the version to use. This field supportsdnfversion specifications:-
For a specific version, use the exact version number such as
9.6.0. -
For the latest available version, use the asterisk
* -
For the latest minor version, use formats such as
9.*.
-
For a specific version, use the exact version number such as
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"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 defines collection of keys and their corresponding 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, such asname = "package-name"andversion = "package-version". Each subsequent instance adds a new element in the order that you define them.
-
The
-
Save the file, for example, as
<blueprint_name>.tomland close the text editor.
4.4. Creating a system image with RHEL image builder on the command line Copy linkLink copied to clipboard!
To build a customized RHEL image by using the RHEL image builder command-line interface, you must specify a blueprint and an image type. Optionally, you can also specify a distribution.
If you do not specify a distribution, it uses the same distribution and version as the host system. The architecture is also the same as the one on the host.
Prerequisites
- You have a blueprint prepared for the image.
Procedure
Optional: List the image formats you can create:
# image-builder listStart the compose:
# image-builder build <image_type> --blueprint <blueprint_name>-
Replace
<blueprint_name>with the name of the blueprint, and<image_type>with the type of the image. -
If you do not specify a distro,
image-builderuses the same distribution and version as the host system.
-
Replace
Result
The compose process takes some minutes to complete. You can follow the image building steps until the image is ready.
After the image building process finishes, the image is available for your use at the directory where you create it.
4.5. Basic RHEL image builder command-line commands Copy linkLink copied to clipboard!
Use the RHEL image builder command-line interface to run these basic image-builder commands.
- List all available images
# image-builder list- Filter images by name
# image-builder list-images --filter "rhel"- Filter by distribution and architecture
# image-builder list-images --filter "distro:rhel-10 arch:s390x"- Change output format
# image-builder list-images --filter "distro:rhel-10" --format=json | jq# image-builder list-images --filter "distro:rhel-10" --format=shell- Building images
# image-builder build <image-type><image-type> is the image type supported for RHEL image builder, such as
qcow2,wsl, and so on.- Specify a distribution
# image-builder build <image-type> --distro <distro>- Show the progress of the image creation and detailed steps
# image-builder build <image-type> --distro <distro> --with-buildlog- Cross-architecture build
# image-builder build <image-type> --arch=riscv64- Add a custom repository to the build
# image-builder build <image-type> --add-repo=<file:///path/to/my/repo>
4.6. Enabled services on custom images Copy linkLink copied to clipboard!
When you configure a custom image by using RHEL image builder to the RHEL version and image type determine the default services that the image uses.
For example, use the ami image type to enable the sshd, chronyd, and cloud-init services by default. If these services are not enabled, the custom image does not boot.
| Image type | Default enabled Services |
|---|---|
|
| sshd, cloud-init, cloud-init-local, cloud-config, cloud-final |
|
| sshd, cloud-init, cloud-init-local, cloud-config, cloud-final |
|
| cloud-init |
|
| Do not enable extra services by default |
|
| sshd, chronyd, waagent, cloud-init, cloud-init-local, cloud-config, cloud-final |
|
| sshd, chronyd, vmtoolsd, cloud-init |
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.
Chapter 5. Supported image customizations Copy linkLink copied to clipboard!
You can customize your image by adding customizations to your blueprint, such as adding an additional RPM package, enabling a service, or customizing a kernel command line parameter.
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 the RHEL image builder.
5.1. Selecting a distribution Copy linkLink copied to clipboard!
You can use the distro field to specify the distribution to use when composing your images or solving dependencies in the blueprint.
If you leave the distro field empty, the blueprint uses the host distribution. Use repository overrides to download base system RPMs from a custom mirror instead of the Red Hat Content Delivery Network (CDN). This disables the default repositories, so your custom mirror must contain all necessary packages.
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.
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.
Prerequisites
- You have created a blueprint.
Procedure
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"For example:
name = "tmux" description = "tmux image with openssh" version = "1.2.16" distro = "rhel-9.6"Replace
"different_minor_version"to build a different minor version, for example, if you want to build a RHEL 9.6 image, usedistro = "rhel-96". On RHEL 9.5 image, you can build minor versions such as RHEL 9.4, RHEL 9.3, and earlier releases.
5.2. Selecting a package group Copy linkLink copied to clipboard!
Customize the blueprint with package groups. The groups list describes the groups of packages that you want to install into the image.
Package groups are defined in the repository metadata, each group with a descriptive name and an ID. Use the ID to list a group. Groups categorize packages as mandatory, default, or optional. The blueprint installs only mandatory and default packages, and you cannot select optional packages.
The name attribute is a required string and must match exactly the package group ID in the repositories.
Currently, there are no differences between packages and modules. Both are treated as RPM package dependencies.
Prerequisites
- You have created a blueprint.
Procedure
Customize your blueprint with a package group:
[[groups]] name = "<group_name>"Replace
group_namewith the name of the group. For example:[[groups]] name = "anaconda-tools"
5.3. Selecting a package Copy linkLink copied to clipboard!
Customize the blueprint with packages and modules.
-
The
nameattribute is a required string and can be an exact match, or a filesystem glob that uses*for wildcards, and?for character matching. -
The optional
versionattribute accepts an exact match or a glob pattern using*for wildcards, and?for character matching. If you do not enter a version, the system uses the latest version in the repositories.
When you use a virtual provider as the package name, the version glob must be *. Consequently, you are not able to freeze the blueprint because the provider expands into multiple packages with their own names and versions.
Currently, there are no differences between packages and modules. RHEL image builder treat both as an RPM package dependencies.
Prerequisites
- You have created a blueprint.
Procedure
Customize your blueprint with a package:
[[packages]] name = "<package_name>"Replace
package_namewith the name of the package. For example, thetmux-2.9aand theopenssh-server-8.*packages.[[packages]] name = "tmux" version = "2.9a" [[packages]] name = "openssh-server" version = "8.*"
5.4. Embedding a container Copy linkLink copied to clipboard!
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. Reference to the container image at a registry. This example uses theregistry.access.redhat.comregistry. You can specify a tag version. The default tag version is the 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 file customization.
Prerequisites
- You have created a blueprint.
Procedure
To embed a container from
registry.access.redhat.com/ubi10/ubi:latestand a container from your host, add the following customization to your blueprint:[[containers]] source = "registry.access.redhat.com/ubi10/ubi:latest" name = local_name tls-verify = true [[containers]] source = "localhost/test:latest" local-storage = trueYou can access protected container resources by using a
containers-auth.jsonfile. See Container registry credentials.
5.5. Setting the image hostname Copy linkLink copied to clipboard!
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.
Prerequisites
- You have created a blueprint.
Procedure
Customize the blueprint to configure the hostname:
[customizations] hostname = "<base_image>"
5.6. Specifying host resources in a blueprint Copy linkLink copied to clipboard!
You can use the URI field to reference files from external sources.
By using the URI field in the blueprint file customization structure, you can reference and source files from external locations. This provides flexible customization of the build system beyond files included directly in the blueprint.
Note that this customization currently only supports file URLs.
Prerequisites
- You created a blueprint.
Procedure
Customize the blueprint with a host resource file:
[customizations] name = "<user_name>" description = "<user_description>" uri = "<file://hostname/path>"Replace
"file://hostname/path"with, for example,"file://localhost/etc/fstab".
5.7. Specifying additional users Copy linkLink copied to clipboard!
Add a user to the image, and optionally, set their SSH key. All fields for this section are optional except for the name.
Prerequisites
- You have created a blueprint.
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 = <uid_number> gid = <gid_number>[[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 = 12345The 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_hashwith the actualpassword hash. To generate thepassword 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())'Replace the other placeholders with suitable values.
Enter the
namevalue and omit any lines you do not need.Repeat this block for every user to include.
5.8. Specifying additional groups Copy linkLink copied to clipboard!
Specify a group for the resulting system image. Both the name and the gid attributes are mandatory.
Prerequisites
- You have created a blueprint.
Procedure
Customize the blueprint with a group:
[[customizations.group]] name = "<group_name>" gid = <number>Repeat this block for every group to include. For example:
[[customizations.group]] name = "widget" gid = 1130
5.9. Setting SSH key for existing users Copy linkLink copied to clipboard!
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.
Prerequisites
- You have created a blueprint.
Procedure
Customize the blueprint by setting an SSH key for existing users:
[[customizations.sshkey]] user = "root" key = "PUBLIC-SSH-KEY"For example:
[[customizations.sshkey]] user = "root" key = "SSH key for root"
5.10. Appending a kernel argument Copy linkLink copied to clipboard!
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.
Prerequisites
- You have created a blueprint.
Procedure
Append a kernel boot parameter option to the defaults:
[customizations.kernel] append = "<kernel_option>"For example:
[customizations.kernel] name = "kernel-debug" append = "nosmt=force"
5.11. Building RHEL images by using the real-time kernel Copy linkLink copied to clipboard!
Build a RHEL image by using the real-time kernel (kernel-rt). Override a repository by using .json from the /usr/share/image-builder/repositories/ directory to build an image that selects kernel-rt as the default kernel. Deploy the image to a system and use the real-time kernel features.
The real-time kernel runs on AMD64 and Intel 64 server platforms that are certified to run Red Hat Enterprise Linux.
Prerequisites
- Your system is registered, and RHEL is attached to a RHEL for Real Time subscription.
Procedure
Create a
kernel.jsonfile to include the RT kernel repository:{ "name": "kernel-rt", "baseurl": "https://cdn.redhat.com/content/dist/rhel10/10/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 },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-10.0" [[customizations.user]] name = "admin" password = "admin" groups = ["users", "wheel"] [customizations.kernel] name = "kernel-rt" append = ""Build your image from the blueprint you created. The following example builds a
.qcow2image:# image-builder build qcow2 -- blueprint rt-kernel-image --data-dir kernel.json- 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 correctly selected
kernel-rtas the default kernel.$ cat /proc/cmdline BOOT_IMAGE=(hd0,got3)/vmlinuz-6.12.0-0.el10_0_.x86_64+rt...
5.12. Setting time zone and NTP Copy linkLink copied to clipboard!
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.
Prerequisites
- You have created a blueprint.
Procedure
Customize the blueprint with the
timezoneand thentpserversyou want:[customizations.timezone] timezone = "TIMEZONE" ntpservers = "NTP_SERVER"For example:
[customizations.timezone] timezone = "US/Eastern" ntpservers = ["0.north-america.pool.ntp.org", "1.north-america.pool.ntp.org"]NoteSome 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.
5.13. Customizing the locale settings Copy linkLink copied to clipboard!
You can customize the locale settings for your resulting system image. Both language and keyboard attributes are mandatory. The first language you add is the primary language, and the remaining languages are secondary.
Prerequisites
- You have created a blueprint.
Procedure
Set the locale settings:
[customizations.locale] languages = ["<language>"] keyboard = "<keyboard>"For example:
[customizations.locale] languages = ["en_US.UTF-8"] keyboard = "us"List the values supported by the languages:
$ localectl list-localesList the values supported by the keyboard:
$ localectl list-keymaps
5.14. Customizing firewall Copy linkLink copied to clipboard!
Set the firewall for the resulting system image. By default, the firewall blocks incoming connections, except for services that you explicitly enabled ports, such as sshd.
If you do not want to use the [customizations.firewall] or [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.
The Google template explicitly disables the firewall for their environment. You cannot override this behavior by setting the blueprint.
Prerequisites
- You have created a blueprint.
Procedure
Customize the blueprint with the following settings to open other ports and services:
[customizations.firewall] ports = ["<ports>"]Where
portsis an optional list of strings that contain ports or a range of ports and protocols to open. You can configure the ports by using theport:protocolformat, or you can configure the port ranges by using theportA-portB:protocolformat. For example:[customizations.firewall] ports = ["22:tcp", "80:tcp", "imap:tcp", "53:tcp", "53:udp", "30000-32767:tcp", "30000-32767:udp"]You can use numeric ports or their names from the
/etc/servicesto enable or disable port lists.Specify which firewall services to enable or disable in the
customizations.firewall.servicesection:[customizations.firewall.services] enabled = ["<services>"] disabled = ["<services>"]You can check the available firewall services:
$ firewall-cmd --get-servicesFor example:
[customizations.firewall.services] enabled = ["ftp", "ntp", "dhcp"] disabled = ["telnet"]NoteThe services listed in
firewall.servicesare different from theservice-namesavailable in the/etc/servicesfile.
5.15. Enabling or disabling services Copy linkLink copied to clipboard!
You can control which services to enable during boot time. Some image types have preset services that you cannot override to ensure the image works correctly.
The [customizations.services] settings add to existing services in image templates but do not replace them.
Prerequisites
- You have created a blueprint.
Procedure
Customize which services to enable during boot time:
[customizations.services] enabled = ["services"] disabled = ["services"]For example:
[customizations.services] enabled = ["sshd", "cockpit.socket", "httpd"] disabled = ["postfix", "telnetd"]
5.16. Kickstart file injection in an ISO image Copy linkLink copied to clipboard!
You can use the [customizations.installer] customization to add your Kickstart file to ISO installers builds, such as image installer, for bare metal deployments.
Booting the ISO on a machine with an existing operating system or data can be destructive, because it configures the Kickstart 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 = truefield in the Kickstart, and getting a fully unattended installation with defaults. Injecting your own Kickstart by using the Kickstart field. This results in a fully unattended installation if you specify all required fields. Otherwise, the installation program prompts you for missing fields.
The Anaconda installer ISO image types support the following blueprint customization:
[customizations.installer] unattended = true sudo-nopasswd = ["user", "%wheel"]unattended: Creates a Kickstart file that fully automates the installation. This includes setting the following options by default:- text display mode
-
en_US.UTF-8language and locale -
us keyboardlayout -
UTC time zone -
zerombr,clearpart, andautopartto automatically wipe and partition the first disk -
network options to enable
dhcpandauto-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
sudo-nopasswd: Use to add a Kickstart snippet configured to create /etc/sudoers.d drop-in files, enabling specified users and % prefixed groups to run sudo without a password.
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
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
"""
image-builder automatically adds the command that installs the system: liveimg, if it is relevant for the image-installer image type. You cannot use the [customizations.installer.kickstart] customization in combination with any other installer customizations.
5.17. Specifying a partition mode Copy linkLink copied to clipboard!
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 is 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 is no extra mount points. -
raw: It uses raw partitions even when there are one or more mount points.
Prerequisites
- You have created a blueprint.
Procedure
You can customize your blueprint with the
partitioning_modevariable by using the following customization:[customizations] partitioning_mode = "lvm"
5.18. Custom file system configuration specification Copy linkLink copied to clipboard!
You can specify a custom filesystem 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
The OSTree systems do not support filesystem customizations, because OSTree images have their own mount rule, such as read-only. The following image types are not supported:
-
image-installer
Additionally, the following image types do not support filesystem customizations, because these image types do not create partitioned operating system images:
-
tar -
container
For release distributions before 9.4, the blueprint supports the following mountpoints and their sub-directories:
-
/is the root mount point -
/var -
/home -
/opt -
/srv -
/usr -
/app -
/data -
/tmp
You cannot specify arbitrary custom mount points on the following mount points 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 filesystem in the blueprint for the /usr custom mount point, but its subdirectory is not allowed.
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 filesystem configuration in your blueprint and therefore create images with the required disk layout. The default filesystem 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. Specify the parent directory in the [[customizations.directories]] customization to ensure that it exists.
Combining file customizations with other blueprint customizations might affect their functioning or override the file customizations.
5.18.1. Custom files specification in the blueprint Copy linkLink copied to clipboard!
With the [[customizations.files]] blueprint customization you can create new text files, or modify existing files. 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.
If you use the customizations.directories with a directory path that 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.
5.18.2. Custom directories specification in the blueprint Copy linkLink copied to clipboard!
You can use the [[customizations.directories]] blueprint customization to create or modify directories.
With the 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.
- Modify existing files. 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
The following customizations are available:
Customize the filesystem configuration in your blueprint:
[[customizations.filesystem]] mountpoint = "MOUNTPOINT" minsize = MINIMUM-PARTITION-SIZEThe
MINIMUM-PARTITION-SIZEvalue 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 = 1073741824Define the mount point size by using units. For example:
[[customizations.filesystem]] mountpoint = "/opt" minsize = "20 GiB"[[customizations.filesystem]] mountpoint = "/var" minsize = "1 GiB"Define the minimum partition by setting
minsize. For example:[[customizations.filesystem]] mountpoint = "/var" minsize = 2147483648Create customized directories under the
/etcdirectory 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 = booleanThe blueprint entries are described as follows:
-
pathMandatory. Enter the path to the directory that you want to create. It must be an absolute path under the/etcdirectory. -
modeOptional. Set the access permission on the directory, in the octal format. If you do not specify a permission, it defaults to0755. The leading zero is optional. -
userOptional. Set a user as the owner of the directory. If you do not specify a user, it defaults toroot. You can specify the user as a string or as an integer. -
groupOptional. Set a group as the owner of the directory. If you do not specify a group, it defaults toroot. You can specify the group as a string or as an integer. -
ensure_parentsOptional. Specify whether you want to create parent directories as needed. If you do not specify a value, it defaults tofalse.
-
Create a customized file under the
/etcdirectory 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!"The blueprint entries are described as follows:
-
pathMandatory. Enter the path to the file that you want to create. It must be an absolute path under the/etcdirectory. -
modeOptional. Set the access permission on the file in the octal format. If you do not specify a permission, it defaults to0644. The leading zero is optional. -
userOptional. Set a user as the owner of the file. If you do not specify a user, it defaults toroot. You can specify the user as a string or as an integer. -
groupOptional. Set a group as the owner of the file. If you do not specify a group, it defaults toroot. You can specify the group as a string or as an integer. -
dataOptional. Specify the content of a plain text file. If you do not specify any content, it creates an empty file.
-
5.19. Volume groups and logical volumes naming specification in the blueprint Copy linkLink copied to clipboard!
You can specify the names of volume groups and logical volumes in the blueprint.
You can use RHEL image builder for the following operations:
-
Create RHEL disk images with an 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/bootdirectories by using theconfig.tomlfile. -
Select which file system to use. You can choose between
ext4andxfs. - Add swap partitions and LVs. The disk images can contain LV-based SWAP.
- Change the 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.
You can add custom names for VG and LG where the file systems reside, for example:
[[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"
Chapter 6. Creating system images by using RHEL image builder web console interface Copy linkLink copied to clipboard!
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.
6.1. Accessing the RHEL image builder dashboard in the RHEL web console Copy linkLink copied to clipboard!
With the cockpit-image-builder plugin for the RHEL web console, you can manage image builder blueprints and composes by using a graphical interface.
Prerequisites
- You must have root access to the system.
- You installed RHEL image builder.
-
You installed the
cockpit-image-builderpackage.
Procedure
-
On the host, open
https://localhost:9090/in a web browser. - Log in to the web console as the root user.
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.
6.2. Creating a blueprint in the web console interface Copy linkLink copied to clipboard!
Before creating your customized RHEL system image, you must create a blueprint. All customizations are optional.
Prerequisites
- You opened the RHEL image builder application from the web console in a browser. See Accessing RHEL image builder GUI in the RHEL web console.
Procedure
-
Click Create Blueprint. On the
Image outputpage, selectReleaseversion,Architecture, and target environment, then click Next. -
Optional: On the
File system configurationpage, selectManually configure partitionsto add mount points, such as/var,/home,/tmpand specifyMinimum size partition. Click Next. -
Optional: On the
Additional packagespage, search for packages, move them toChosen packages, then click Next. -
Optional: On the
Userspage, click Add user to enter aUsername, aPassword, anSSH key, andAdministratorprivileges. Click Next -
Optional: On the
Timezonepage, enter a time zone, for example, "US/Eastern" andNTPservers. Click Next. -
Optional: On the
Localepage, enter the languages and keyboard identifier. For example: "us" and ["en_US.UTF-8"]. Click Next. -
Optional: On the
HostnameandKernelpages, add a hostname, and kernel command-line arguments. Click Next after each page. -
Optional: On the
FirewallandSystemd servicespages, configureport, firewall services, and systemd services to enable or disable. Click Next after each page. -
On the
Detailspage, enter the blueprint name and optional description, then click Next. -
On the
Reviewpage, review the details and click Create blueprint or Create blueprint and build image(s).
6.3. Importing a blueprint in the RHEL image builder web console interface Copy linkLink copied to clipboard!
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
-
On the RHEL image builder dashboard, click . The
Import blueprintwizard opens. -
From the
Uploadfield, either drag or upload an existing blueprint. This blueprint can be in eitherTOMLorJSONformat. - Click . 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
Packagestab.- To list all the package dependencies, click . The list is searchable and can be ordered.
Next steps
Optional: To modify any customization:
-
From the
Customizationsdashboard, click the customization you want to make a change to. Optionally, you can click to navigate to all the available customization options.
-
From the
6.4. Exporting a blueprint from the RHEL image builder web console interface Copy linkLink copied to clipboard!
You can export a blueprint to use the customizations in another system. You can export the blueprint in the TOML or in 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
- On the image builder dashboard, select the blueprint you want to export.
-
Click
Export blueprint. TheExport blueprintwizard opens. Click the button to download the blueprint as a file or click the button to copy the blueprint to the clipboard.
- Optional: Click the button to copy the blueprint.
Verification
- Open the exported blueprint in a text editor to inspect and review it.
6.5. Creating a system image by using RHEL image builder in the web console interface Copy linkLink copied to clipboard!
You can create a customized RHEL system image from a customized blueprint by completing these steps.
Prerequisites
- You opened the RHEL image builder app from the web console in a browser.
- You created a blueprint.
Procedure
- In the RHEL image builder dashboard, click the blueprint tab.
- On the blueprint table, find the blueprint you want to build an image.
- On the right side of the chosen blueprint, click Create Image. The Create image dialog wizard opens.
On the Image output page, complete the following steps:
- From the Select a blueprint list, select the image type you want.
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.
- Click Next.
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.
-
On the RHEL image builder dashboard, click the
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.
-
On the RHEL image builder dashboard, click the
Chapter 7. Creating a boot ISO installer image with RHEL image builder Copy linkLink copied to clipboard!
You can use RHEL image builder to create bootable ISO Installer images. These images consist of a .tar file that has a root file system. You can use the bootable ISO image to install the file system to a bare-metal server.
RHEL image builder builds a manifest that creates a boot ISO that contains a root file system. To create the ISO image, select the image type image-installer. RHEL image builder builds a .tar file with the following content:
- A standard Anaconda installer ISO
- An embedded RHEL system tar file
- A default Kickstart file that installs the commit with minimal default requirements
The created installer ISO image includes a pre-configured system image that you can install directly to a bare-metal server.
7.1. Creating a boot ISO installer image using the RHEL image builder CLI Copy linkLink copied to clipboard!
You can create a customized boot ISO installer image by using the RHEL image builder command-line interface. The resulting image is an .iso file that contains a .tar file, which you can install on your operating system.
The .iso file is set up to boot Anaconda and install the .tar file for setting up the system. You can use the created ISO image file on a hard disk or to boot in a virtual machine, such as an HTTP Boot or a USB installation.
The installation (.iso) image type does not accept partition customization. If you try to manually configure the filesystem customization, it is not applied to any system built by the (.iso) image. ISO image built with file system customizations might cause Kickstart errors, and the installation does not reboot automatically. For more information, see Automate a RHEL ISO installation generated by image builder.
Prerequisites
- You have created a blueprint for the image and customized it with a user included and pushed it back into RHEL image builder. See Supported image customizations.
Procedure
Create the ISO image:
# image-builder build iso --blueprint <blueprint_name>-
<blueprint_name>with the name of the blueprint you created <image_installer>is the image typeThe compose process starts and might take some minutes complete.
RHEL image builder builds an
.isofile that contains a.tarfile. The.tarfile is the image that is installed for the operating system. The.isois set up to boot Anaconda and install the.tarfile to set up the system.
-
Next steps
j In the directory where you downloaded the image file.
-
Locate the
.isoimage that you built. Mount the ISO image.
$ mount -o ro <path_to_iso> /mntYou can find the
.tarfile at the/mnt/liveimg.tar.gzdirectory.List the
.tarfile content:$ tar ztvf /mnt/liveimg.tar.gz
7.2. Creating a boot ISO installer image by using RHEL image builder in the GUI Copy linkLink copied to clipboard!
You can build a customized boot ISO installer image by using the RHEL image builder GUI. You can use the resulting ISO image file on a hard disk or boot it in a virtual machine. For example, in an Hypertext Transfer Protocol (HTTP) Boot or a Universal Serial Bus (USB) installation.
The installation (.iso) image type does not accept partitions customization. If you try to manually configure the filesystem customization, it is not applied to any system built by the installation image. Mounting an ISO image built with RHEL image builder file system customizations causes an error in the Kickstart, and the installation does not reboot automatically. For more information, see Automate a RHEL ISO installation generated by image builder.
Prerequisites
- You have opened the RHEL image builder app from the web console in a browser.
- You have created a blueprint for your image. See Creating a RHEL image builder blueprint in the web console interface.
Procedure
- On the RHEL image builder dashboard, locate the blueprint that you want to use to build your image. Optionally, enter the blueprint name or a part of it into the search box at the upper left, and click Enter.
On the right side of the blueprint, click the corresponding button.
The Create image dialog wizard opens.
On the Create image dialog wizard:
-
In the Image Type list, select
"RHEL Installer (.iso)". - Click .
On the Review tab, click Create.
After the build process is complete, you can see the image build complete status.
-
In the Image Type list, select
Verification
After the image is successfully created, you can download it.
-
Click Download to save the
"RHEL Installer (.iso)"image to your system. -
Navigate to the folder where you downloaded the
"RHEL Installer (.iso)"image. -
Locate the
.tarimage you downloaded. Extract the
"RHEL Installer (.iso)"image content.$ tar -xf <content>.tar
7.3. Installing a bootable ISO to a medium and booting it Copy linkLink copied to clipboard!
Install the bootable ISO image you created by using RHEL image builder on a bare metal system.
Prerequisites
- You created the bootable ISO image by using RHEL image builder.
- You have downloaded the bootable ISO image.
-
You installed the
ddtool. - You have a USB flash drive with enough capacity for the ISO image. The required size varies depending on the packages you selected in your blueprint, but the minimum size is 8 GB.
Procedure
Write the bootable ISO image directly to the USB drive using the
ddtool. For example:dd if=installer.iso of=/dev/sdXWhere
installer.isois the ISO image file name and/dev/sdXis your USB flash drive device path.- Insert the flash drive into a USB port of the computer you want to boot.
Boot the ISO image from the USB flash drive.
When the installation environment starts, you might need to complete the installation manually, similarly to the default Red Hat Enterprise Linux installation.
Chapter 8. Creating pre-hardened images with RHEL image builder OpenSCAP integration Copy linkLink copied to clipboard!
RHEL image builder on-premise supports the OpenSCAP integration. This integration enables the production of pre-hardened RHEL images.
By setting up a blueprint, you can perform the following actions:
- Customize it with a set of predefined security profiles
- Add a set of packages or add-on files
- Build a customized RHEL image ready to deploy on your chosen platform that is more suitable for your environment
Red Hat provides regularly updated versions of the security hardening profiles that you can choose when you build your systems so that you can meet your current deployment guidelines.
8.1. The OpenSCAP blueprint customization Copy linkLink copied to clipboard!
By using the OpenSCAP blueprint customization, you can generate blueprints from the scap-security-guide for specific security profiles and build pre-hardened images.
Creating a customized blueprint with OpenSCAP involves the following high-level steps:
- Modify the mount points and configure the file system layout according to your specific requirements.
-
In the blueprint, select the OpenSCAP profile. This configures the image to trigger the remediation during the image build in accordance with the selected profile. Also, during the image build, OpenSCAP applies a
pre-first-bootremediation.
To use the OpenSCAP blueprint customization in your image blueprints, you need to provide the following information:
-
The data stream path to the
datastreamremediation instructions. The data stream files fromscap-security-guidepackage are located in the/usr/share/xml/scap/ssg/content/directory. -
The
profile_idof the required security profile. Theprofile_idfield accepts both long and short forms, such ascisorxccdf_org.ssgproject.content_profile_cis. See SCAP Security Guide profiles supported in RHEL 10 for more details.
The following example is a snippet with the OpenSCAP remediation stage:
[customizations.openscap]
# If you want to use the data stream from the 'scap-security-guide' package
# the 'datastream' key could be omitted.
# datastream = "/usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml"
profile_id = "xccdf_org.ssgproject.content_profile_cis"
You can find more details about the SCAP source data stream from the scap-security-guide package, including the list of security profiles it provides, by using the command:
# oscap info /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
For your convenience, the OpenSCAP tool can generate the hardening blueprint for any profile available in scap-security-guide data streams.
For example, the command:
# oscap xccdf generate fix --profile=cis --fix-type=blueprint /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
generates a blueprint for CIS profile similar to the following example:
# Blueprint for CIS Red Hat Enterprise Linux 10.0 Benchmark for Level 2 - Server
# Profile Description:
# This profile defines a baseline that aligns to the "Level 2 - Server"
# configuration from the Center for Internet Security® Red Hat Enterprise
# Linux 10 Benchmark™, v3.0.0, released 2023-10-30.
# This profile includes Center for Internet Security®
# Red Hat Enterprise Linux 10.0 CIS Benchmarks™ content.
#
# Profile ID: xccdf_org.ssgproject.content_profile_cis
# Benchmark ID: xccdf_org.ssgproject.content_benchmark_RHEL-10.0
# Benchmark Version: 0.1.74
# XCCDF Version: 1.2
name = "hardened_xccdf_org.ssgproject.content_profile_cis"
description = "CIS Red Hat Enterprise Linux 10.0 Benchmark for Level 2 - Server"
version = "0.1.74"
[customizations.openscap]
profile_id = "xccdf_org.ssgproject.content_profile_cis"
# If your hardening data stream is not part of the 'scap-security-guide' package
# provide the absolute path to it (from the root of the image filesystem).
# datastream = "/usr/share/xml/scap/ssg/content/ssg-xxxxx-ds.xml"
[[customizations.filesystem]]
mountpoint = "/home"
size = 1073741824
[[customizations.filesystem]]
mountpoint = "/tmp"
size = 1073741824
[[customizations.filesystem]]
mountpoint = "/var"
size = 3221225472
[[customizations.filesystem]]
mountpoint = "/var/tmp"
size = 1073741824
[[packages]]
name = "aide"
version = "*"
[[packages]]
name = "libselinux"
version = "*"
[[packages]]
name = "audit"
version = "*"
[customizations.kernel]
append = "audit_backlog_limit=8192 audit=1"
[customizations.services]
enabled = ["auditd","crond","firewalld","systemd-journald","rsyslog"]
disabled = []
masked = ["nfs-server","rpcbind","autofs","bluetooth","nftables"]
Do not use this exact blueprint snippet for image hardening. It does not reflect a complete profile. As Red Hat constantly updates and refines security requirements for each profile in the scap-security-guide package, it makes sense to always re-generate the initial template by using the most up-to-date version of the data stream provided for your system.
Now you can customize the blueprint or use it as it is to build an image.
By using RHEL image builder, you can generate the necessary configurations for the stage based on your blueprint customization. This action adds two packages to the image:
-
openscap-scanneris theOpenSCAPtool. scap-security-guideis the package that contains the remediation and evaluation instructions.The remediation stage uses the
scap-security-guidepackage for the datastream because this package is installed on the image by default. If you want to use a different datastream, add the necessary package to the blueprint and specify the path to the datastream in theoscapconfiguration.
8.2. Creating a pre-hardened image with RHEL image builder Copy linkLink copied to clipboard!
Use RHEL image builder on-premise to create pre-hardened RHEL images with support to the OpenSCAP integration.
By setting up a blueprint, you can perform the following actions:
- Create images that are pre-hardened and compliant with a specific profile
- Deploy the pre-hardened images in a Virtual Machine (VM), or a bare-metal environment, for example.
Prerequisites
-
You are logged in as the root user or a user who is a member of the
weldrgroup. -
The
openscapandscap-security-guidepackages are installed.
Procedure
Create a hardening blueprint in the Tom’s Obvious Minimal Language (TOML) format, using the
OpenSCAPtool andscap-security-guidecontent, and modify it if necessary:# oscap xccdf generate fix --profile=<profileID> --fix-type=<blueprint> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml > cis.tomlReplace
<profileID>with the profile ID that the system should comply with, for example,cis.Start the build of hardened image:
# image-builder build <image_type> --blueprint <blueprint_name>Replace
<image_type>with any image type, for example,qcow2.After the image build is ready, you can use your pre-hardened image on your deployments. See Creating a virtual machine from a Kernel-based Virtual Machine (KVM) guest image.
Verification
After you deploy your pre-hardened image, you can perform a configuration compliance scan to verify that the image is aligned with the selected security profile.
Performing a configuration compliance scanning does not guarantee the system is compliant. For more information, see Configuration compliance scanning.
8.3. Customizing a pre-hardened image with RHEL image builder Copy linkLink copied to clipboard!
You can customize a security profile by changing rule, such as password length, removing or selecting rules to implement internal policies. You cannot define new rules by customizing a profile.
Building an image from the blueprint creates a tailoring file and saves it to /usr/share/xml/oscap-tailoring/tailoring.xml with a new tailoring profile ID. The new profile ID have tailoring appended as a suffix to the base profile. For example, if you use the Center for Internet Security (CIS) (cis) base profile, the profile ID is xccdf_org.ssgproject.content_profile_cis_tailoring.
Prerequisites
-
You are logged in as the root user or a user who is a member of the
weldrgroup. -
The
openscapandscap-security-guidepackages are installed.
Procedure
Create a hardening blueprint in the TOML format from a selected profile. For example:
# oscap xccdf generate fix --profile=<profileID> --fix-type=blueprint /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml > <profileID>tailored.tomlAppend the tailoring section with the customized rule set to the blueprint. The tailoring customization only affects the default selected or unselected state of rules in the base profile without changing the state of other rules.
# Blueprint for CIS Red Hat Enterprise Linux 10.0 Benchmark for Level 2 - Server # ... [customizations.openscap.tailoring] selected = [ "xccdf_org.ssgproject.content_bind_crypto_policy" ] unselected = [ "grub2_password" ]Start the build of a hardened image:
# *image-builder build <image_type> --blueprint <blueprintProfileID> *Replace
<image_type>with any image type, for example,qcow2.After the image build is ready, use your pre-hardened image on your deployments.
Verification
After you deploy your pre-hardened image, you can perform a configuration compliance scan to verify that the image is aligned with the selected security profile.
Performing a configuration compliance scanning does not guarantee the system is compliant. For more information, see Configuration compliance scanning.
Chapter 9. Enabling FIPS mode with RHEL image builder Copy linkLink copied to clipboard!
You can create a customized image and boot a FIPS-enabled RHEL image. Before you compose the image, you must change the value of the fips directive in your blueprint.
Prerequisites
-
You are logged in as the root user or a user who is a member of the
weldrgroup.
Procedure
Create a plain text file in the Tom’s Obvious, Minimal Language (TOML) format with the following content:
name = "system-fips-mode-enabled" description = "blueprint with FIPS enabled" version = "0.0.1" [customizations] fips = true [[customizations.user]] name = "admin" password = "admin" groups = ["users", "wheel"]Build the customized RHEL image:
# image-builder build image-type --blueprint blueprint-name
Verification
- Log in to the system image with the username and password that you configured in your blueprint.
Check if FIPS mode is enabled:
$ cat /proc/sys/crypto/fips_enabled 1
Chapter 10. Generating a WSL 2 image with RHEL image builder Copy linkLink copied to clipboard!
You can use the RHEL image builder to create a Windows Subsystem for Linux (WSL). After building the image in the .wsl format, you can deploy it locally by double-clicking the image.
Windows Subsystem for Linux (WSL) runs Linux distributions alongside your Windows environment. WSL images support the following image customizations:
-
cloud-init - distro
- packages
- modules
- groups
- minimal
Note that WSL images do not support the locale and file system customizations. You cannot configure file system and storage options because WSL instances do not have their own disk images by design.
Prerequisites
- An existing blueprint.
-
A Windows system with the
wslcommand installed. See How to install Linux on Windows with WSL.
Procedure
Build the customized RHEL image:
# image-builder build wsl --blueprint <blueprint-name>Download the image:
# image-builder image <UUID>RHEL image builder downloads the image to the current directory path. The UUID and the image size are displayed:
$ UUID-image-name. type: size MBThe image filename defaults to using the unique identifier included in the filename, such as
af9e8627867e-image.wsl. The unique identifier number is provided to thewsl.exeutility.-
Import the
wslimage to the Microsoft Windows system and start the image installation.
Chapter 11. Preparing and deploying a KVM Guest Image by using RHEL image builder Copy linkLink copied to clipboard!
Use RHEL image builder to create a .qcow2 image that you can deploy on a Kernel-based Virtual Machine (KVM) based hypervisor.
Creating a customized KVM guest image involves the following high-level steps:
-
Create a blueprint for the
.qcow2image. -
Create a
.qcow2image by using RHEL image builder. - Create a virtual machine from the KVM guest image.
11.1. Creating customized KVM guest images by using RHEL image builder Copy linkLink copied to clipboard!
You can create a customized .qcow2 Kernel-based Virtual Machine (KVM) guest image by using the GUI RHEL image builder.
Prerequisites
-
You must be in the
rootorweldrgroup to access the system. -
The
cockpit-image-builderpackage is installed. - On a RHEL system, you have opened the RHEL image builder dashboard of the web console.
- You have created a blueprint. See Creating a blueprint in the web console interface.
Procedure
- Click the blueprint name you created.
- Select the tab Images.
- Click Create Image to create your customized image. The Create Image window opens.
-
From the Type drop-down menu list, select
QEMU Image(.qcow2). - Set the size that you want the image to be when instantiated and click Create.
- A small pop-up on the upper right side of the window informs you that the image creation has been added to the queue. After the image creation process is complete, you can see the Image build complete status.
Verification
-
Click the breadcrumbs icon and select the Download option. RHEL image builder downloads the KVM guest image
.qcow2file to your default download location.
11.2. Creating a virtual machine from a KVM guest image Copy linkLink copied to clipboard!
Create a new VM from a KVM Guest Image by using the .qcow2 image that you created by using RHEL image builder. The customized image already has cloud-init installed and enabled.
Prerequisites
-
You created a
.qcow2image by using RHEL image builder. -
You have the
qemu-kvmpackage installed on your system. You can check if the/dev/kvmdevice is available on your system, and if virtualization features are enabled in the firmware. -
You have the
libvirtandvirt-installpackages installed on your system. -
You have the
genisoimageutility, which is provided by thexorrisopackage, installed on your system.
Procedure
-
Move the
.qcow2image that you created by using RHEL image builder to the/var/lib/libvirt/images/directory. Create a directory, for example,
cloudinitiso, and navigate to this newly created directory:$ mkdir cloudinitiso $ cd cloudinitisoCreate a file named
meta-data. Add the following information to this file:instance-id: citest local-hostname: vmnameCreate a file named
user-data. Add the following information to the file:# cloud-config user: admin password: password chpasswd: {expire: False} ssh_pwauth: True ssh_authorized_keys: - ssh-rsa AAA...fhHQ== your.email@example.comssh_authorized_keysis your SSH public key. You can find your SSH public key in~/.ssh/id_rsa.pub\.Use the
genisoimageutility to create an ISO image that includes theuser-dataandmeta-datafiles.# genisoimage -output cloud-init.iso -volid cidata -joliet -rock user-data meta-data I: -input-charset not specified, using utf-8 (detected in locale settings) Total translation table size: 0 Total rockridge attributes bytes: 331 Total directory bytes: 0 Path table size(bytes): 10 Max brk space used 0 183 extents written (0 MB)Create a new VM from the KVM Guest Image by using the
virt-installcommand. Include the ISO image you created in step 4 as an attachment to the VM image.# virt-install \ --memory 4096 \ --vcpus 4 \ --name myvm \ --disk rhel-10-x86_64-kvm.qcow2,device=disk,bus=virtio,format=qcow2 \ --disk cloud-init.iso,device=cdrom \ --os-variant rhel 10 \ --virt-type kvm \ --graphics none \ --import-
--graphicsnone means it is a headless RHEL 10 VM. -
--vcpus 4means that it uses 4 virtual CPUs. -
--memory 4096means it uses 4096 MB RAM.
-
The VM installation starts:
Starting install... Connected to domain mytestcivm ... [ OK ] Started Execute cloud user/final scripts. [ OK ] Reached target Cloud-init target. Red Hat Enterprise Linux 10 (Ootpa) Kernel 4.18.0-221.el8.x86_64 on an x86_64
Verification
After the boot is complete, the VM shows a text login interface. To log in to the local console of the VM, you can use the details from the user-data file:
-
Enter
adminas a username and press . Enter
passwordas password and press .After the login authentication is complete, you have access to the VM by using the CLI.
Chapter 12. Creating Vagrant boxes with RHEL image builder Copy linkLink copied to clipboard!
With RHEL image builder, you can choose between the vagrant-libvirt or vagrant-virtualbox image types to create Vagrant boxes.
RHEL image builder generates pre-configured images optimized for different hypervisors:
-
vagrant-libvirtcreates a QCOW2-based image forlibvirt -
vagrant-virtualboxcreates a VMDK-based image forVirtualBox
The pre-configured images include the vagrant user with sudo privileges. This configuration simplifies administrative tasks within the Vagrant box.
The images are supported in the following architectures: aarch64 and x86_64.
12.1. Building Vagrant images for the libvirt and VirtualBox backends Copy linkLink copied to clipboard!
You can use RHEL image builder to create custom Vagrant boxes for different providers by using the vagrant-libvirt and vagrant-virtualbox image types.
-
The
vagrant-libvirtimage type creates aQCOW2-based box for use with thelibvirtprovider. -
The
vagrant-virtualboximage type creates a box compatible with theVirtualBoxprovider.
You can customize the image type by using blueprint customizations.
Prerequisites
- RHEL image builder is installed and running.
- You have a blueprint file ready to build.
-
For the
libvirt box: A host system with thelibvirthypervisor is installed and running. -
For the
VirtualBoxbox: A host system withVirtualBoxis installed.
Procedure
Build the Vagrant box image:
For
libvirt:$ sudo image-builder build --distro rhel-10.0 vagrant-libvirtFor
VirtualBox:$ sudo image-builder build - -distro <distro-name> vagrant-virtualboxThis creates a
.boxfile.
Import the new
.boxfile to your local Vagrant environment. You must explicitly set theprovidertovirtualboxbecause it is not the standard provider.$ vagrant box add --provider=virtualbox <path/to/box> --name=<box-name>Replace
path/to/image-name.boxwith the actual path to your file and<box_name>with a name such asrhel10-vagrant.Create a new directory for your project, and initialize Vagrant:
$ mkdir <my_vagrant_project> $ cd <my_vagrant_project> $ vagrant init <box-name>This creates the
Vagrantfileconfiguration file and sets its default box to <box-name>.Launch the virtual machine by using Vagrant:
$ vagrant up
Chapter 13. Pushing a container to a registry and embedding it into an image Copy linkLink copied to clipboard!
With RHEL image builder, you can build security-hardened images by using the OpenSCAP tool. You can take advantage of the support for container customization in the blueprints to create a container and embed it directly into the image you create.
13.1. Customizing a blueprint to embed a container into an image Copy linkLink copied to clipboard!
Embed a container from registry.access.redhat.com by adding a container customization to your blueprint. RHEL image builder pulls the container during the image build and stores the container in the image.
The default local container storage location depends on the image type, so that all supported container-tools, such as Podman, can work with it.
Prerequisites
- You have created a blueprint.
Procedure
- Customize your blueprint with the container:
[[containers]]
source = "registry.access.redhat.com/ubi10/ubi:latest"
name = "_<local_name>_"
tls-verify = true
-
source- Mandatory field. It is a reference to the container image at a registry. This example uses theregistry.access.redhat.comregistry. You can specify a tag version. The default tag version is thelatest. -
name- The name of the container in the local registry. tls-verify- Boolean field. Thetls-verifyboolean field controls the transport layer security. The default value istrue.To access protected container resources, you can use a
containers-auth.jsonfile.
13.2. Pushing a container artifact directly to a container registry Copy linkLink copied to clipboard!
You can push container artifacts directly to a container registry after you build them by using the RHEL image builder CLI.
Prerequisites
-
Access to quay.io registry. This example uses the
quay.iocontainer registry as a target registry, but you can use a container registry of your choice.
Procedure
Set up a
registry-config.tomlfile to select the container provider. The credentials are optional.provider = "<container_provider>" [settings] tls_verify = false username = "<admin>" password = "<your_password>"Create a blueprint in the
.tomlformat. This is a blueprint for the container in which you install annginxpackage into the blueprint.name = "simple-container" description = "Simple RHEL container" version = "0.0.1" [[packages]] name = "nginx" version = "*"Build the container image, by passing the registry and the repository to the
image-buildertool as arguments.# image-builder build --blueprint <simple-container> --extra-repo "quay.io:8080/<namespace>/<repository>" --extra-repo registry-config.tomlNoteBuilding the container image takes time because of resolving dependencies of the customized packages.
- After the image build finishes, the container you created is available in quay.io.
Verification
Open quay.io and click
Repository Tags. You can see details about the container you created, such as:- Last modified
- Image size
-
The
manifest IDthat you can copy to the clipboard.
-
Copy the
manifest IDvalue to build the image in which you want to embed a container.
13.3. Building an image and pulling the container into the image Copy linkLink copied to clipboard!
After you create a container image, build your customized image and pull the container image into it. Use the container customization specification in the blueprint and the container name for the final image. It fetches the container image and add it to the local Podman container storage.
Prerequisites
-
You created a container image and pushed it into your local
quay.iocontainer registry instance. See Pushing a container artifact directly to a container registry. - You have access to registry.access.redhat.com.
-
You have a container
manifest ID. -
You have the
qemu-kvmandqemu-imgpackages installed.
Procedure
Create a blueprint to build a
qcow2image. The blueprint must contain the[[containers]]customization.name = "image" description = "A qcow2 image with a container" version = "0.0.1" distro = "rhel-10" [[packages]] name = "podman" version = "*" [[containers]] source = "registry.access.redhat.com/ubi10:8080/image/container/container-image@sha256:manifest-ID-from-Repository-tag: tag-version" name = "source" tls-verify = trueBuild the container image:
# image-builder build qcow2 --blueprint <blueprint>NoteBuilding the image takes time because it checks the container on
quay.ioregistry.You can use the
qcow2image you created and downloaded to create a VM.
Verification
-
Locate the resulting
qcow2image. -
Start the
qcow2image in a VM. See Creating a virtual machine from a KVM guest image. -
The
qemuwizard opens. Log in to theqcow2image by entering the username and password. These can be the username and password you set up in the.qcow2blueprint in thecustomizations.usersection, or created at boot time withcloud-init. Run the container image and open a shell prompt inside the container:
# podman run -it registry.access.redhat.com/ubi10:8080/<organization>/<repository>/bin/bash/registry.access.redhat.comis the target registry,<organization>is the organization, andrepositoryis the location to push the container when it finishes building.Check that the packages you added to the blueprint are available:
# type -a nginxThe output shows you the
nginxpackage path.
Chapter 14. Preparing and uploading cloud images by using RHEL image builder Copy linkLink copied to clipboard!
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 environment, create the image with RHEL image builder, choose the output type, configure your system, and upload the image to your cloud account.
You can push customized image clouds by using the Image Builder application in the RHEL web console, available for a subset of the service providers that RHEL image builder supports, such as AWS and Microsoft Azure clouds.
Chapter 15. Preparing and uploading AMI images to AWS Copy linkLink copied to clipboard!
You can create custom images and update them, either manually or automatically, on the AWS cloud with RHEL image builder.
15.1. Preparing to manually upload AWS AMI images Copy linkLink copied to clipboard!
Before uploading an Amazon Web Services Machine image (AWS AMI) image, you must configure a system for uploading the images.
Prerequisites
- You must have an Access Key ID configured in the AWS IAM account manager.
- You must have a writable S3 bucket prepared.
Procedure
Install Python 3 and the
piptool:# dnf install python3 python3-pipInstall the AWS command-line tools with
pip:# pip3 install awscliSet 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]:Define a name for your bucket and create a bucket:
$ BUCKET=bucketname $ aws s3 mb s3://$BUCKETReplace
bucketnamewith the actual bucket name. It must be a globally unique name. As a result, your bucket is created.To grant Simple Storage Service (S3) access permission, create a
vmimportrole in the AWS Identity and Access Management (IAM), if you have not already.Create a
trust-policy.jsonfile with the trust policy configuration in JSON format. For example:{ "Version": "2022-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "Service": "vmie.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "sts:Externalid": "vmimport" } } }] }Create a
role-policy.jsonfile 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 $BUCKETCreate a role for your Amazon Web Services account, by using the
trust-policy.jsonfile:$ aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.jsonEmbed an inline policy document by using the
role-policy.jsonfile:$ aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document file://role-policy.json
15.2. Manually uploading an AMI image to AWS by using the CLI Copy linkLink copied to clipboard!
You can use RHEL image builder to build ami images and manually upload them directly to the Amazon AWS Cloud service provider by using the CLI.
Prerequisites
Procedure
Build the image:
# image-builder build ami \ --blueprint blueprint-name \ --aws-region us-east-1 \ --aws-bucket <example-bucket> \ --aws-ami-name <image-name> \Upload the image to AWS:
# image-builder upload <image-name> \
Verification
- Confirm the image upload by accessing EC2 in the AWS console and selecting the correct region.
- On the dashboard, select your image and click .
15.3. Creating and automatically uploading images to the AWS Cloud AMI Copy linkLink copied to clipboard!
You can create a .raw image by using RHEL image builder and select Upload to AWS to automatically push the image to the Amazon AWS Cloud AMI service provider.
Prerequisites
-
You must have
rootorwheelgroup 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
- In the RHEL image builder dashboard, select your blueprint in blueprint name. Select the Images tab, and click Create Image.
-
From the Type drop-down menu list, select
Amazon Machine Image Disk (.raw), check Upload to AWS, and click Next. Enter your
AWS access key IDandAWS secret access keyin the corresponding fields. Click Next.NoteIf you do not know your Secret Key, generate a new Access Key ID.
-
Enter the
Image name`,Amazon S3 bucketname, andAWS region, then click Next. - Review the information and click Finish. Wait for the Image build complete status.
-
In the AWS console, navigate to Service→EC2, select the correct region, and verify your image shows
Availablestatus. - Select your image, click Launch, choose an instance type, and click Review and Launch.
Review instance details, click Launch, then select or create a key pair:
- To create a new key pair, select Create a new key pair, enter a name, and click Download Key Pair.
- Click Launch Instance and wait the instance status to change to running.
Click Connect, then use SSH to access your instance:
$ chmod 400 <your_instance_name>.pem $ ssh -i <your-instance_name>.pem ec2-user@<your-instance-IP-address>-
Type
yesto confirm the connection.
-
Type
Verification
- Check if you are able to perform any action while connected to your instance by using SSH.
Chapter 16. Preparing and uploading VHD images to Microsoft Azure Copy linkLink copied to clipboard!
You can create custom images and update them, either manually or automatically, on the Microsoft Azure cloud by using RHEL image builder.
16.1. Preparing to upload Microsoft Azure VHD images manually Copy linkLink copied to clipboard!
To create a virtual hard drive (VHD) image that you can manually upload to the 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 CLItool depends on Python.
Procedure
Import the Microsoft repository key:
$ sudo rpm --import https://packages.microsoft.com/keys/microsoft-2025.ascCreate a
packages-microsoft-com-prodrepository:[azure-cli] name=Azure CLI baseurl=https://packages.microsoft.com/yumrepos/packages.microsoft.com/rhel/10/prod/ enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.ascInstall Microsoft Azure CLI. The downloaded version of the Microsoft Azure CLI package can vary depending on the currently available version.
$ sudo dnf install azure-cliRun Microsoft Azure CLI:
$ az loginThe 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 the Login from where you can log in.NoteIf you are running a remote (SSH) session, the login page link does not open in the browser. In this case, you can copy the link to a browser and log in to authenticate your remote session. To sign in, use a web browser to open the Login page and enter the device code to authenticate.
List the keys for the storage account in Microsoft Azure and make note of the value
key1from the output of the previous command.$ az storage account keys list --resource-group <resource_group_name> --account-name <account_name>Replace
resource-group-namewith the name of your Microsoft Azure resource group andstorage-account-namewith the name of your Microsoft Azure storage account.To list the available resources using the following command:
$ az resource list
Create a storage container:
$ az storage container create --account-name <storage_account_name> \ --account-key <key1_value> --name <storage_account_name>Replace
storage-account-namewith the name of the storage account.
16.2. Manually uploading VHD images to Microsoft Azure cloud Copy linkLink copied to clipboard!
Create your customized virtual hard disk (VHD) image, and manually upload it to the Microsoft Azure cloud. When you create a .vhd image by using the CLI, RHEL image builder writes temporary files to the /var subdirectory.
The partition and filesystem configurations in your blueprint determine .vhd image size. Insufficient storage might cause a “No space left on device” error. Ensure /var has at least 15 to 20 GB of free space.
Prerequisites
- Your system must be set up for uploading Microsoft Azure VHD images.
- You have an Azure access key storage account.
Procedure
Create a
azure.tomlblueprint, and add the following information to it:provider = "azure" [settings] storageAccount = "<your-storage-account-name>" storageAccessKey = "<storage-access-key-you-copied-in-the-Azure-portal>" container = "<your-storage-container-name>"Build the image, passing the following arguments:
$ image-builder build <your-blueprint> vhd <your-image-key> azure.tomlReplace <your-image-key> with the name of the image that you want.
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 pageAfter the upload to the Microsoft Azure Blob storage completes, create a Microsoft Azure image from it. The images that you create with RHEL image builder generate hybrid images that support
V1 = BIOSandV2 = UEFI. Use--hyper-v-generationto specify instance type.V1is the default.$ 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
Verification
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-
Use your private key by using SSH to access the resulting instance. Log in as
azure-user.
16.3. Creating and automatically uploading VHD images to Microsoft Azure cloud Copy linkLink copied to clipboard!
By using RHEL image builder, you can create .vhd images, which are automatically uploaded to an Azure Blob Storage in the Microsoft Azure Cloud service provider.
Prerequisites
- You have root access to the system.
- You have access to the RHEL image builder interface of the RHEL web console.
- You created a blueprint. See Creating a RHEL image builder blueprint in the web console interface.
- You have a Microsoft Storage Account created.
- You have a writable Blob Storage prepared.
Procedure
-
In the RHEL image builder dashboard, select your blueprint, click the Images tab, and click Create Image to create your customized
.vhdimage. -
Select
Microsoft Azure (.vhd)from the Type drop-down, check Upload to Azure, enter the Image Size, and click Next. - Enter your Storage account name and your Storage access key then, click Next.
- Review the configuration and click Create. The RHEL image builder and upload processes start.
-
In the Microsoft Azure portal navigate to Storage accounts > Containers and verify if your
.vhdis present.
Verification
In the Azure portal search bar, type Images and click +Create. Configure the following details:
- Select your resource group and enter an image name.
- Set OS type to Linux and VM generation to Gen 2.
- Under Storage Blob, browse to select your VHD file.
- Choose an Account Type, for example, Standard SSD.
- Click Review + Create, and then Create. Wait for the image creation to complete.
- Click Go to resource, then click Create VM. Enter a VM name, configure the Size and Administrator account sections, then click Review + Create and Create.
After the deployment finishes, retrieve the public IP address and connect by using SSH.
$ ssh <username>@<public-IP-address>
Chapter 17. Preparing and uploading VMDK custom images to vSphere Copy linkLink copied to clipboard!
You can create custom images and update them, either manually or automatically, to the VMware vSphere cloud by using RHEL image builder.
17.1. Creating and automatically uploading customized RHEL VMDK images by using image builder Copy linkLink copied to clipboard!
With RHEL image builder, you can create customized system images in the Open Virtualization Format (OVA), and automatically upload these images to the VMware vSphere client.
The OVA (.ova) is a .vmdk image with additional metadata about the virtual hardware, which contains a minimal template to make it easier to import images into vSphere. The .ovf (Open Virtualization Format) package is part of the vSphere .ova image. After RHEL image builder finishes importing the .ova image in the vSphere client, you can configure it with any additional hardware, such as network, disks, and CD-ROMs.
You can import the Open virtualization format (.ova) image by using either the vSphere GUI or the govc client. To upload the image by using the govc client, see Uploading VMDK images and creating a RHEL virtual machine in vSphere.
Prerequisites
- You opened the RHEL image builder app from the web console in a browser.
- You created a blueprint.
Procedure
-
In the RHEL image builder dashboard, click the
Blueprinttab. - On the blueprint table, find the blueprint you want to build an image.
- On the right side of the chosen blueprint, click Create Image. The Create image dialog wizard opens.
On the Image output page, complete the following steps:
- From the Select a blueprint list, select the image type you want.
- From the Image output type list, select the image output type you want.
- Optional: Check Upload to VMware checkbox to upload the image directly to VMware.
- Enter a size for the image.
- Click Next.
On the Upload to VMware page, enter the following information:
- Image name: Enter the image name.
- Host: Enter the VMware vSphere instance URL where you want to upload the image file.
- Cluster: Enter the cluster name page where you want to upload the image.
- Datacenter: The data center name where you want to upload the image.
- Datastore: The data store name where you want to upload the image.
- Folder: Folder name where you want to upload the image.
- Click Next.
On the Review page, review the details about the image creation and click Create.
The image creation starts, showing the progress of this image creation and the subsequent upload to the VMware vSphere client.
17.2. Uploading VMDK images and creating a RHEL virtual machine in vSphere Copy linkLink copied to clipboard!
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 customized 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.
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
.ovaor the.vmdkformat by using RHEL image builder and downloaded it to your host system. -
You installed and configured the
govcCLI tool to be able to use theimport.vmdkcommand.
Procedure
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- Navigate to the directory where you downloaded your VMware vSphere image.
Launch the VMware vSphere image on vSphere by following the steps:
Import the VMware vSphere image into vSphere:
$ govc import.vmdk ./api.vmdk <folder-name>For the
.ovaformat:$ govc import.ova ./api.ova <folder-name>
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="<folder-name>/api.vmdk” \ -disk.controller=scsi -on=false \ vmnameFor the
.ovaformat, replace the line-firmware=efi -disk="folder_name/api.vmdk”with-firmware=efi -disk=”<folder-name>/api.ova”Power-on the VM:
$ govc vm.power -on <vm-name>Retrieve the VM IP address:
$ govc vm.ip <vm-name>Use SSH to log in to the VM, using the username and password you specified in your blueprint:
$ ssh admin@ <vm-ip-address>NoteUsing images copied with the
govc datastore.uploadcommand is not supported. The vSphere GUI does not supportimport.vmdkcommand or direct, so.vmdkimages are not usable from the vSphere GUI.
17.3. Creating and automatically uploading VMDK images to vSphere using image builder GUI Copy linkLink copied to clipboard!
You can build VMware images by using the RHEL image builder Graphical User Interface (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 that 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 the vSphere instances service provider, follow the steps:
Prerequisites
-
You are a member of the
rootor theweldrgroup. - You have opened RHEL image builder in a browser.
- You have created a blueprint.
- You have a vSphere Account.
Procedure
- For the blueprint you created, click the Images tab .
Click Create Image to create your customized image.
The Image type window opens.
In the Image type window:
-
From the dropdown menu, select the Type: VMware vSphere (
.vmdk). - Check the Upload to VMware checkbox to upload your image to vSphere.
- Optional: Set the size of the image you want to instantiate. The minimal default size is 2 GB.
- Click Next.
-
From the dropdown menu, select the Type: VMware vSphere (
In the Upload to VMware window, under Authentication, enter the following details:
- Username: username of the vSphere account.
- Password: password of the vSphere account.
In the Upload to VMware window, under Destination, enter the following details about the image upload destination:
- Image name: a name for the image.
- Host: The URL of your VMware vSphere.
- Cluster: The name of the cluster.
- Data center: The name of the data center.
- Data store: The name of the Data store.
- Click Next.
In the Review window, review the details of the image creation and click Finish.
You can click Back to modify any incorrect details.
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.
After the process is complete, you can see the Image build complete status.
Verification
- Create a Virtual Machine (VM) from the image you uploaded and log in to it.
- Access VMware vSphere Client and search for the image in the Cluster.
-
Select the image, open its menu, and click
New Virtual Machine. In the New Virtual Machine window, configure the following details:
-
Select
New Virtual Machine, and specify a name and a folder for your VM. -
Select a computer resource and storage. For example, select
NFS-Node1. -
Select compatibility,
BIOSonly, a guest operating system. For example,LinuxandRed Hat Fedora (64-bit). -
In Customize hardware, delete the default New Hard Disk and select an
Existing Hard Diskdisk image:
-
Select
- Review the configuration and click Finish.
- Navigate to the VMs tab, select the VM, and click Start.
- Log in with the credentials you created in the blueprint.
Optional: Verify that the packages you added to the blueprint are installed. For example:
$ rpm -qa | grep firefox
Chapter 18. Preparing and uploading custom GCE images to Google Cloud Copy linkLink copied to clipboard!
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.
18.1. Configuring and uploading a gce image to Google Cloud by using the CLI Copy linkLink copied to clipboard!
Set up a configuration file with credentials to upload your gce image to GCP by using the RHEL image builder CLI.
You cannot manually import gce image to Google Cloud, because the image does 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 Google Cloud. 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 Google Cloud bucket.
Procedure
Use a text editor to create a
gcp-config.tomlconfiguration file with the following content:provider = "gcp" [settings] bucket = "<gcp_bucket>" region = "<gcp_storage_region>" object = "<object_key>" credentials = "<gcp_credentials>"-
<gcp_bucket>points to an existing bucket. This field stores the intermediate storage object of the image to be 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 when the upload process finishes, it is deleted . If the object name does not end with.tar.gz, the object name automatically adds the extension. <gcp_credentials>is aBase64-encodedscheme of the credentials JSON file downloaded from Google Cloud. The credentials determine which project the Google Cloud uploads the image to.NoteSpecifying
<gcp_credentials>in thegcp-config.tomlfile is optional if you use a different mechanism to authenticate with Google Cloud. For other authentication methods, see Authenticating with Google Cloud.
-
Retrieve the
<gcp_credentials>from the JSON file downloaded from Google Cloud.$ sudo base64 -w 0 cee-gcp-nasa-476a1fa485b7.jsonCreate a compose with an additional image name and cloud provider profile:
$ sudo image-builder build gce --blueprint <blueprint_name> <image_key> gcp-config.tomlThe image build, upload, and cloud registration processes can take up to ten minutes to complete.
Verification
Verify that the image status is FINISHED:
$ sudo image-builder compose status
18.2. How RHEL image builder sorts the authentication order of different Google Cloud credentials Copy linkLink copied to clipboard!
You can use several different types of credentials with RHEL image builder to authenticate with GCP. If you set RHEL image builder configuration to authenticate with GCP by using multiple sets of credentials, it uses the credentials in an order of preference.
The order of preference is as follows:
-
Credentials specified with the
image-buildercommand in the configuration file. Application Default Credentialsfrom theGoogle Cloud SDKlibrary, which tries to automatically find a way to authenticate by using the following options:- If you set the GOOGLE_APPLICATION_CREDENTIALS environment variable, Application Default Credentials tries to load and use credentials from the file that the variable points to.
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.
NoteYou must use the Google Cloud credentials to determine which Google Cloud project to upload the images to. To upload to different projects, specify the credentials in
gcp-config.tomlwith theimage-buildercommand.
Chapter 19. Preparing and uploading custom images directly to OCI Copy linkLink copied to clipboard!
You can create custom images and automatically update them to the Oracle Cloud Infrastructure (OCI) instance by using RHEL image builder.
19.1. Creating and automatically uploading custom images to OCI Copy linkLink copied to clipboard!
With RHEL image builder, you can 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
rootorweldrgroup user access to the system. - You have an Oracle Cloud account.
- You must have security access in an OCI policy.
-
You have created an OCI Bucket in the
OCI_REGIONof your choice.
Procedure
- Open the RHEL image builder interface of the web console in a browser.
- Click Create blueprint. The Create blueprint wizard opens.
- On the Details page, enter a name for the blueprint, and optionally, a description. Click Next.
- On the Packages page, select the components and packages that you want to include in the image. Click Next.
- On the Customizations page, configure the customizations that you want for your blueprint. Click Next.
- On the Review page, click Create.
- To create an image, click Create Image. The Create image wizard opens.
On the Image output page, complete the following steps:
- From the "Select a blueprint" drop-down menu, select the blueprint you want.
-
From the "Image output type" drop-down menu, select
Oracle Cloud Infrastructure (.qcow2). - Check the Upload to OCI checkbox to upload your image to the OCI.
- Enter the "image size". Click Next.
On the Upload to OCI - Authentication page, enter the following mandatory details:
- User OCID: You can find it in the Console on the page showing the user’s details.
- Private key
On the Upload to OCI - Destination page, enter the following mandatory details and click Next.
- Image name: a name for the image that you want to upload.
- OCI bucket
- Bucket namespace
- Bucket region
- Bucket compartment
- Bucket tenancy
Review the details in the wizard and click Finish.
RHEL image builder adds the compose of a RHEL
.qcow2image to the queue.
Verification
- Access the OCI dashboard and click Custom Images.
- Select the Compartment you specified for the image and locate the image in the Import image table.
- Click the image name and verify the image information.
Chapter 20. Preparing and uploading customized QCOW2 images directly to OpenStack Copy linkLink copied to clipboard!
You can create custom .qcow2 images with RHEL image builder and manually upload them to the OpenStack cloud deployments.
20.1. Uploading QCOW2 images to OpenStack Copy linkLink copied to clipboard!
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.
Prerequisites
- You have created a blueprint.
Procedure
Start the compose of a
QCOW2image.# image-builder build qcow2 --blueprint blueprint_name- Access the OpenStack dashboard and click .
-
On the left menu, select the
Admintab. From the
System Panel, clickImage.The
Create An Imagewizard opens.In the
Create An Imagewizard:- Enter a name for the image
-
Click
Browseto upload theQCOW2image. -
From the
Formatdropdown list, select theQCOW2 - QEMU Emulator. - Click .
On the left menu, select the
Projecttab.-
From the
Computemenu, selectInstances. Click the button.
The
Launch Instancewizard opens.-
On the
Detailspage, enter a name for the instance. Click . -
On the
Sourcepage, select the name of the image you uploaded. Click . -
On the
Flavorpage, select the machine resources that best fit your needs. Click .
-
From the
-
You can run the image instance using any mechanism such as the CLI or OpenStack web UI from the image. Use your private key by using SSH to access the resulting instance. Log in as
cloud-user.
Chapter 21. Preparing and uploading customized RHEL images to the Alibaba Cloud Copy linkLink copied to clipboard!
You can upload customized .ami images that you created by using RHEL image builder to the Alibaba Cloud.
21.1. Creating an instance of a customized RHEL image using Alibaba Cloud Copy linkLink copied to clipboard!
You can create instances of a customized RHEL image by using the Alibaba ECS Console.
Prerequisites
- You have activated OSS and uploaded your custom image.
- You have successfully imported your image to ECS Console.
Procedure
- Log in to the ECS console.
- On the left-side menu, select Instances.
- In the upper-right corner, click Create Instance. A new window opens.
- Complete all the required information. See Creating an instance by using the custom launch for more details.
Click Create Instance and confirm the order.
NoteYou 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.
21.2. Importing images to Alibaba Cloud Copy linkLink copied to clipboard!
You can import a customized Alibaba RHEL image that you created by using RHEL image builder to the Elastic Compute Service (ECS).
Prerequisites
- Your system is set up for uploading Alibaba images.
-
You have created an
amiimage by using RHEL image builder. - You have a bucket. See Creating a bucket.
- You have an active Alibaba Account.
- You activated OSS.
- You have uploaded the image to Object Storage Service (OSS).
Procedure
- Log in to the ECS console, click , then click . A dialog window opens.
- Confirm the correct region and enter the following information:
-
OSS Object Address: Obtain from OSS Object Address. -
Image Name,Operating System,System Disk Size,System Architecture. Platform: Red Hat-
Optional: Provide
Image Format(qcow2orami),Image Description, andAdd Images of Data Disksdetails. - Click OK and wait for the import to complete.
- Log in to the OSS console and select your bucket from the left menu.
- Click the Files, then click Upload.
- Configure Upload To to the current or specified directory, and File ACL for permission type.
Click Upload, select your image, then click Open.
ECSConsole imports the customized image.
-
Optional: Provide
21.3. Uploading customized RHEL images to Alibaba Copy linkLink copied to clipboard!
You can upload a customized AMI image you created by using RHEL image builder to the Object Storage Service (OSS).
Prerequisites
- Your system is set up for uploading Alibaba images.
-
You have created an
amiimage by using RHEL image builder. - You have a bucket. See Creating a bucket.
- You have an active Alibaba Account.
- You activated OSS.
Procedure
- Log in to the OSS console.
- In the Bucket menu on the left, select the bucket to which you want to upload an image.
- In the upper right menu, click the Files tab.
Click . 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.
- Click .
- Select the image you want to upload to the OSS Console.
- Click .
21.4. Preparing to upload customized RHEL images to Alibaba Cloud Copy linkLink copied to clipboard!
To deploy a customized RHEL image to the Alibaba Cloud, first, you must verify the customized image. The image requires a specific configuration to boot, because Alibaba Cloud custom images must meet certain requirements.
RHEL image builder generates images that conform to the requirements of Alibaba. However, you must use 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
-
Connect to the system containing the image that you want to check by using the Alibaba
image_checktool. Download the
image_checktool:$ curl -O https://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/73848/cn_zh/1557459863884/image_checkChange the file permission of the image compliance tool:
# chmod +x image_checkRun the command to start the image compliance tool checkup:
# ./image_checkThe tool verifies the system configuration and generates a report that in your screen. The
image_checktool 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 them.