Composing a customized RHEL system image
Creating customized system images with RHEL image builder on RHEL 10.0
摘要
Providing feedback on Red Hat documentation 复制链接链接已复制到粘贴板!
We appreciate your feedback on our documentation. Let us know how we can improve it.
Submitting feedback through Jira (account required)
- Log in to the Jira website.
- 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 dialogue.
第 1 章 RHEL image builder description 复制链接链接已复制到粘贴板!
To deploy a system, create a system image. To create RHEL system images, use the RHEL image builder tool. You can use RHEL image builder to create customized system images of Red Hat Enterprise Linux, including system images prepared for deployment on cloud platforms. RHEL image builder automatically handles the setup details for each output type. It is therefore easier to use and faster to work with than manual methods of image creation. You can access the RHEL image builder functionalities by using the image-builder 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 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
RHEL image builder can create images in multiple output formats shown in the table.
| Description | CLI name | File extension |
|---|---|---|
| Architecture | Amazon Web Services |
|
| [filename]`.ami |
| 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 复制链接链接已复制到粘贴板!
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.
第 2 章 Installing RHEL image builder 复制链接链接已复制到粘贴板!
RHEL image builder is a tool for creating custom system images. Before using RHEL image builder, you must install it.
2.1. RHEL image builder system requirements 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
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
第 3 章 Configuring RHEL image builder repositories 复制链接链接已复制到粘贴板!
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 if you want to download base system RPMs from elsewhere than the Red Hat Content Delivery Network (CDN) official repositories, for example, a custom mirror in your network. Using official repository 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.
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> \ --add-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, they will be selected over the default repositories.
You can add additional custom repositories, and specify a distribution to your image during the image-building time by using the image-builder tool and the --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> \ --add-repo <file:///path/to/my/repo> \ --distro rhel-10.0 \
3.3. Overriding a system repository during image build 复制链接链接已复制到粘贴板!
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> \警告Note that the repositories defined are used to solve all dependencies, which could cause issues for your system.
You can use Satellite’s content views (CV) as repositories to build images with RHEL image builder. Configure the repository references on your host registered on Satellite to retrieve from the Satellite repositories instead of the Red Hat Content Delivery Network (CDN) official repositories.
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> \
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.
RHEL image builder is a tool for creating custom system images. To control RHEL image builder and create your custom system images, you can use the command line (CLI) or the web console interface.
You can use the RHEL image builder command-line interface (CLI) to create blueprints, by running the 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, the image-builder command offers many subcommands to examine the state of configured blueprints and composes.
4.2. RHEL image builder blueprint format 复制链接链接已复制到粘贴板!
RHEL image builder supports blueprints in both the .toml and .json formats.
A typical blueprint file include 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. This field supportsdnfversion specifications:-
For a specific version, use the exact version number, such as
8.7.0. -
For the latest available version, use the asterisk
*. For the latest minor version, use a format such as
8.*.Repeat this block for every package to include.
注意There are no differences between packages and modules in the RHEL image builder tool. Both are treated as RPM package dependencies.
-
For a specific version, use the exact version number, such as
4.3. Creating a blueprint by using the command line 复制链接链接已复制到粘贴板!
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 is defined by a 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, for example,name = "package-name"andversion = "package-version", and each subsequent instance creates and defines a new table element in that array, in the order that you defined them.
-
The
-
Save the file, for example, as
<blueprint_name>.tomland close the text editor.
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 distro it is installed.The compose process starts and take 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 复制链接链接已复制到粘贴板!
The RHEL image builder command-line interface offers these basic commands for the image-builder.
- 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, between others.- 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 复制链接链接已复制到粘贴板!
When you use RHEL image builder to configure a custom image, the default services that the image uses are determined by specifications, such as the RHEL version release on which you use the image-builder utility, and the image type.
For example, the ami image type enables the sshd, chronyd, and cloud-init services by default. If these services are not enabled, the custom image does not boot.
| 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 |
|
| No extra service is enabled 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.
第 5 章 Supported image customizations 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
You can use the distro field to specify the distribution to use when composing your images or solving dependencies in the blueprint.
If the distro field is left blank, the blueprint automatically uses the host’s operating system distribution. If you do not specify a distribution, the blueprint uses the host distribution. When you upgrade the host operating system, blueprints without a specified distribution build images by using the upgraded operating system version.
You can build images for older major versions on a newer system. For example, you can use a RHEL 10 host to create RHEL 9 and RHEL 8 images. However, you cannot build images for newer major versions on an older system.
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 复制链接链接已复制到粘贴板!
Customize the blueprint with package groups. The groups list describes the groups of packages that you want to install into the image.
The package groups are defined in the repository metadata. Each group has a descriptive name used primarily for display in user interfaces, and an ID that is commonly used in Kickstart files. In this case, you must use the ID to list a group. Groups have three different ways of categorizing their packages: mandatory, default, and optional. Only mandatory and default packages are installed in the blueprints. It is not possible to select optional packages.
The name attribute is a required string and must match exactly the package group ID in the repositories.
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:
[[groups]] name = "<group_name>"Replace
group_namewith the name of the group. For example:[[groups]] name = "anaconda-tools"
5.3. Selecting a package 复制链接链接已复制到粘贴板!
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
versionattribute is an optional string can be an exact match or a filesystem glob of the version that uses*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. Both are treated 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 group. 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 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
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 more flexible customization of the build system and a more adaptable build experience, as it is not limited to 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 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
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 was built with the
kernel-rtcorrectly selected as 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 复制链接链接已复制到粘贴板!
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"]注意Some image types, such as Google Cloud, already have NTP servers set up. You cannot override it because the image requires the NTP servers to boot in the selected environment. However, you can customize the time zone in the blueprint.
5.13. Customizing the locale settings 复制链接链接已复制到粘贴板!
You can customize the locale settings for your resulting system image. Both language and keyboard attributes are mandatory. You can add many other languages. 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 复制链接链接已复制到粘贴板!
Set the firewall for the resulting system image. By default, the firewall blocks incoming connections, except for services that explicitly enable their 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 the following format:port:protocolformat. 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"]注意The services listed in
firewall.servicesare different from theservice-namesavailable in the/etc/servicesfile.
5.15. Enabling or disabling services 复制链接链接已复制到粘贴板!
You can control which services to enable during boot time. Some image types already have services enabled or disabled to ensure that the image works correctly, and you cannot override this setup.
The [customizations.services] settings in the blueprint do not replace these services, even though they add the services to the list of services already present in the image templates.
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 复制链接链接已复制到粘贴板!
You can use the [customizations.installer] blueprint customization to add your own Kickstart file in your builds for ISO installers, such as image installer, and gain more flexibility when building ISO images for bare metal deployments.
Booting the ISO on a machine with an existing operating system or data can be destructive, because the Kickstart is configured to automatically reformat the first disk on the system.
You can choose the following options to add your own Kickstart file:
- Setting all values during the installation process.
-
Enabling the
unattended = truefield in the Kickstart, and getting a fully unattended installation with defaults. Injecting your own Kickstart by using the Kickstart field. This can result in either a fully unattended installation if you specify all required fields, or the installation program prompts you for some fields that might be missing.
The Anaconda installer ISO image types support the following blueprint customization:
[customizations.installer] unattended = true sudo-nopasswd = ["user", "%wheel"]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: Adds a snippet to the Kickstart file that, after installation, creates drop-in files in /etc/sudoers.d to allow the specified users and groups to run sudo without a password. The groups must be prefixed with %. For example, setting the value to ["user", "%wheel"] creates the following Kickstart %post section:
%post
echo -e "user\tALL=(ALL)\tNOPASSWD: ALL" > "/etc/sudoers.d/user"
chmod 0440 /etc/sudoers.d/user
echo -e "%wheel\tALL=(ALL)\tNOPASSWD: ALL" > "/etc/sudoers.d/%wheel"
chmod 0440 /etc/sudoers.d/%wheel
restorecon -rvF /etc/sudoers.d
%end
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 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
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 -
/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. Ensure that the parent directory exists by specifying it in the [[customizations.directories]] customization.
If you combine the file customizations with other blueprint customizations, it might affect the functioning of the other customizations, or it might override the current file customizations.
5.18.1. Custom files specification in the blueprint 复制链接链接已复制到粘贴板!
With the [[customizations.files]] blueprint customization you can create new text files, or modify existing files.
+ WARNING: This can override the existing content. * Set user and group ownership for the file you are creating. * Set the mode permission in the octal format.
You cannot create or replace the following files:
-
/etc/fstab -
/etc/shadow -
/etc/passwd -
/etc/group
You can create customized files and directories in your image by using the [[customizations.files]] and the [[customizations.directories]] blueprint customizations. You can use these customizations only in the /etc directory.
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.
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.
- Modifying existing files. WARNING: This can override the existing content.
- Set user and group ownership for the file you are creating.
- Set the mode permission in the octal format.
You cannot create or replace the following files:
-
/etc/fstab -
/etc/shadow -
/etc/passwd -
/etc/group
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.
-
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"
RHEL image builder is a tool for creating custom system images. To control RHEL image builder and create your custom system images, you can use the web console interface.
With the cockpit-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 复制链接链接已复制到粘贴板!
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 in the upper-right corner.
The Images dialog box opens.
On the
Image outputpage, complete the following steps:-
Choose the
Releaseversion and theArchitecture. - Select the target environment or target environments.
- Click Next.
-
Choose the
Optional: On the
File system configurationpage, selectUse automatic partitioningorManually configure partitionsfor your image file system. To manually configure the partitions, complete the following steps:- Click the Manually configure partitions button.
From the dropdown menu, provide details to configure the partitions:
For the
Mount pointfield, select one of the following mount point type options:-
/app -
/boot -
/data -
/home -
/opt -
/srv -
/tmp -
/usr /varYou can also add an additional path to the
Mount point. For example, if you select/varas the mount point and add/tmpas an additional path, the result is/var/tmp. Depending on the mount point type you choose, the file system type changes toxfs.
-
For the
Minimum size partitionfield of the file system, enter the needed minimum partition size. In theMinimum sizedropdown menu, you can use common size units such asGB,MB, orKB. The default unit isGB.Minimum sizemeans that RHEL image builder can still increase the partition sizes if they are too small to create a working image.
To add more partitions, click the Add partition button. If you see the "Duplicate partitions: Only one partition at each mount point can be created." error message, you can fix it by performing one of the following actions:
- Click the Remove button to remove the duplicated partition.
- Choose a new mount point for the partition you want to create.
- After you finish the partitioning configuration, click Next.
Optional: On the
Additional packagespage, complete the following steps:-
In the
Available packagessearch, enter the package name. -
Click the button to move it to the
Chosen packagesfield. - Repeat the previous steps to search and include as many packages as you want.
- Click Next.
-
In the
Optional: On the
Userspage, add users:- Click Add user.
-
Enter a
Username, aPassword, and anSSH key. You can also mark the user as a privileged user by clicking theAdministratorcheckbox. - Click Next
Optional: On the
Timezonepage, set the time zone:On the
Timezonefield, enter the time zone you want to add to your system image. For example, add the following time zone format: "US/Eastern".If you do not set a time zone, the system uses Universal Time Coordinated (UTC) as the default.
-
Enter the
NTPservers. - Click Next.
Optional: On the
Localepage, complete the following steps:-
In the
Languagessearch field, enter the locale identifier you want to add to your system image. For example: "us". -
In the
Keyboardsearch field, enter the locale identifier you want to add to your system image. For example: ["en_US.UTF-8"]. - Click Next.
-
In the
-
Optional: On the
Hostnamepage, add a hostname, then click Next: Optional: On the
Kernelpage, complete the following steps:- Enter the kernel name.
- Add the kernel command-line arguments.
- Click Next.
Optional: On the
Firewallpage, complete the following steps:-
Enter the
portnumbers. - Add the firewall services you want to enable or disable.
- Click Next.
-
Enter the
Optional: On the
Systemd servicespage, add the services that you want to enable or disable:- Enter the service names you want to enable or disable, separating them with a comma, a space, or by pressing Enter.
- Click Next.
On the
Detailspage, complete the following steps:- Enter the name of the blueprint and, optionally, its description.
- Click Next.
On the
Reviewpage, review the blueprint details and choose one of the options from the dropdown menu:- Click Create blueprint.
Click Create blueprint and build image(s).
The RHEL image builder view opens, listing the existing blueprints.
You can import and use an already existing blueprint. The system automatically resolves all the dependencies.
Prerequisites
- You have opened the RHEL image builder app from the web console in a browser.
- You have a blueprint that you want to import to use in the RHEL image builder web console interface.
Procedure
-
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
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.
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
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.
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. 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 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 will be installed for the Operating system. The.isois set up to boot Anaconda and install the.tarfile to set up the system.
-
Next steps
In the directory where you downloaded the image file.
-
Locate the
.isoimage that you builded. 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
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 HTTP Boot or a USB installation.
The Installer (.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 Installer 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.
RHEL image builder adds the compose of a RHEL ISO image to the queue.
After the process is complete, you can see the image build complete status. RHEL image builder creates the ISO image.
-
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
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.
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 复制链接链接已复制到粘贴板!
With the OpenSCAP support for blueprint customization, you can generate blueprints from the scap-security-guide content for specific security profiles and then use the blueprints to build your own 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. The value of theprofile_idfield accepts both the long and short forms, for example, the following are acceptable:cisorxccdf_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 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.
RHEL image builder generates the necessary configurations for the stage based on your blueprint customization. Additionally, RHEL image builder 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.
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:
- Create images that are pre-hardened and compliant with a specific profile
- Deploy the pre-hardened images in a 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 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 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.
You can customize a security profile by changing parameters in certain rules, for example, minimum password length, removing rules that you cover differently, and selecting additional rules, to implement internal policies. You cannot define new rules by customizing a profile.
When you build an image from that blueprint, it creates a tailoring file with a new tailoring profile ID and saves it to the image as /usr/share/xml/oscap-tailoring/tailoring.xml. The new profile ID will have tailoring appended as a suffix to the base profile. For example, if you use the CIS (cis) base profile, the profile ID will be 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. Note that the tailoring customization will only affect the default selected or unselected state of the rules in the profile on which the customization is based, by selecting or deselecting a rule, 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.
第 9 章 Enabling FIPS mode with RHEL image builder 复制链接链接已复制到粘贴板!
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" 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
第 10 章 Generating a WSL 2 image with RHEL image builder 复制链接链接已复制到粘贴板!
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.
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.
You can create a customized .qcow2 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 复制链接链接已复制到粘贴板!
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 user 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.
第 12 章 Creating Vagrant boxes with RHEL image builder 复制链接链接已复制到粘贴板!
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.
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
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.
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.
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.toml注意Building 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.
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. The container image is fetched and added 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>注意Building 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.
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.
第 15 章 Preparing and uploading AMI images to AWS 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
Before uploading an 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 permission to access the S3 bucket, create a
vmimportS3 Role in the AWS Identity and Access Management (IAM), if you have not already done so in the past: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
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 that the image upload was successful by accessing EC2 on the menu and selecting the correct region in the AWS console. The image must have the
availablestatus to indicate that it was successfully uploaded. - On the dashboard, select your image and click .
You can create a .raw image by using RHEL image builder, and choose to check the Upload to AWS checkbox to automatically push the output image that you create directly to the Amazon AWS Cloud AMI service provider.
Prerequisites
-
You must have
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, click the blueprint name that you previously 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
Amazon Machine Image Disk (.raw). - Check the Upload to AWS checkbox to upload your image to the AWS Cloud and click Next.
To authenticate your access to AWS, type your
AWS access key IDandAWS secret access keyin the corresponding fields. Click Next.注意You can view your AWS secret access key only when you create a new Access Key ID. If you do not know your Secret Key, generate a new Access Key ID.
-
Type the name of the image in the
Image namefield, type the Amazon bucket name in theAmazon S3 bucket namefield, and type theAWS regionfield for the bucket you are going to add your customized image to. Click Next. Review the information and click Finish.
Optionally, click Back to modify any incorrect details.
注意You must have the correct IAM settings for the bucket you are going to send your customized image to. This procedure uses the IAM Import and Export, so you have to set up a policy for your bucket before you are able to upload images to it. For more information, see Required Permissions for IAM Users.
-
From the Type drop-down menu list, select
A pop-up on the upper right informs you of the saving progress. It also informs that the image creation has been initiated, the progress of this image creation, and the subsequent upload to the AWS Cloud.
After the process is complete, you can see the Image build complete status.
In a browser, access Service→EC2.
-
On the AWS console dashboard menu, choose the correct region. The image must have the
Availablestatus to indicate that it is uploaded. - On the AWS dashboard, select your image and click Launch.
-
On the AWS console dashboard menu, choose the correct region. The image must have the
- A new window opens. Choose an instance type according to the resources you need to start your image. Click Review and Launch.
- Review your instance start details. You can edit each section if you need to make any changes. Click Launch.
Before you start the instance, select a public key to access it.
You can either use the key pair you already have or you can create a new key pair.
Follow the next steps to create a new key pair in EC2 and attach it to the new instance.
- From the drop-down menu list, select Create a new key pair.
- Enter the name of the new key pair. It generates a new key pair.
- Click Download Key Pair to save the new key pair on your local system.
Then, you can click Launch Instance to start your instance.
You can check the status of the instance, which displays as Initializing.
- After the instance status is running, the Connect button becomes available.
Click Connect. A window is displayed with instructions on how to connect by using SSH.
- Select A standalone SSH client as the preferred connection method to open a terminal.
In the location where you store your private key, ensure that your key is publicly viewable for SSH to work. To do so, run the command:
$ chmod 400 <your_instance_name>.pemConnect to your instance by using its Public DNS:
$ ssh -i <your-instance_name>.pem ec2-user@<your-instance-IP-address>Type
yesto confirm that you want to continue connecting.As a result, you are connected to your instance over SSH.
Verification
- Check if you are able to perform any action while connected to your instance by using SSH.
You can create custom images and update them, either manually or automatically, on the Microsoft Azure cloud by using RHEL image builder.
To create a 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.注意If 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.
After you have created your customized VHD image, you can 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.
To prevent the .vhd image creation from failing, increase the /var subdirectory capacity to at least 15 to 20 GB of free space to ensure availability.
Prerequisites
- Your system must be set up for uploading Microsoft Azure VHD images.
You must have a Microsoft Azure VHD image created by RHEL image builder.
-
In the GUI, use the
Azure Disk Image (.vhd)image type. -
In the CLI, use the
vhdoutput type.
-
In the GUI, use the
Procedure
Build the image:
$ image-builder build <image-type>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. Because the images that you create with RHEL image builder generate hybrid images that support both the
V1 = BIOSandV2 = UEFIinstance types, you can specify the--hyper-v-generationargument. The default instance type isV1.$ 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. This username was set on the previous step.
By using RHEL image builder, you can create .vhd images, which will be 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 the blueprint you want to use.
- Click the Images tab.
Click Create Image to create your customized
.vhdimage.The Create image wizard opens.
-
Select
Microsoft Azure (.vhd)from the Type drop-down menu list. - Check the Upload to Azure checkbox to upload your image to the Microsoft Azure Cloud.
- Enter the Image Size and click Next.
-
Select
On the Upload to Azure page, enter the following information:
On the Authentication page, enter:
- Your Storage account name. You can find it on the Storage account page in the Microsoft Azure portal.
- Your Storage access key: You can find it on the Access Key Storage page.
- Click Next.
On the Authentication page, enter:
- The image name.
- The Storage container. It is the blob container to which you will upload the image. Find it under the Blob service section, in the Microsoft Azure portal.
- Click Next.
On the Review page, click Create. The RHEL image builder and upload processes start.
Access the image you pushed into Microsoft Azure Cloud.
- Access the Microsoft Azure portal.
- In the search bar, type "storage account" and click Storage accounts from the list.
- On the search bar, type "Images" and select the first entry under Services. You are redirected to the Image dashboard.
- On the navigation panel, click Containers.
-
Find the container you created. Inside the container is the
.vhdfile you created and pushed by using RHEL image builder.
Verification
Verify that you can create a VM image and launch it.
- In the search bar, type images account and click Images from the list.
- Click +Create.
- From the dropdown list, choose the resource group you used earlier.
- Enter a name for the image.
- For the OS type, select Linux.
- For the VM generation, select Gen 2.
- Under Storage Blob, click Browse and click through the storage accounts and containers until you reach your VHD file.
- Click Select at the end of the page.
- Choose an Account Type, for example, Standard SSD.
- Click Review + Create and then Create. Wait a few moments for the image creation.
To launch the VM, follow the steps:
- Click Go to resource.
- Click + Create VM from the menu bar on the header.
- Enter a name for your virtual machine.
- Complete the Size and Administrator account sections.
Click Review + Create and then Create. You can see the deployment progress.
After the deployment finishes, click the virtual machine name to retrieve the public IP address of the instance to connect by using SSH.
- Open a terminal to create an SSH connection to connect to the VM.
You can create custom images and update them, either manually or automatically, to the VMware vSphere cloud by using RHEL image builder.
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 the image file will be uploaded.
- Cluster: Enter the cluster name page to which the image will be uploaded.
- Datacenter: The data center name to which the image will be uploaded.
- Datastore: The data store name to which the image will be uploaded.
- Folder: Folder name to which the image will be uploaded.
- 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.
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>注意If you copied the
.vmdkimage from your local host to the destination using thegovc datastore.uploadcommand, using the resulting image is not supported. There is no option to use theimport.vmdkcommand in the vSphere GUI and as a result, the vSphere GUI does not support the direct upload. The.vmdkimage is not usable from the vSphere GUI.
You can build VMware images by using the RHEL image builder GUI tool and automatically push the images directly to your vSphere instance. This avoids the need to download the image file and push it manually.
The vmdk 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.
- Search for the image in the Cluster on the vSphere instance you specified.
- Select the image you uploaded.
- Right-click the selected image.
Click
New Virtual Machine.A New Virtual Machine window opens.
In the New Virtual Machine window, provide the following details:
-
Select
New Virtual Machine. - Select a name and a folder for your VM.
- Select a computer resource: choose a destination computer resource for this operation.
- Select storage: For example, select NFS-Node1
-
Select compatibility: The image should be
BIOSonly. -
Select a guest operating system: For example, select
LinuxandRed Hat Fedora (64-bit). - Customize hardware: When creating a VM, on the Device Configuration button on the upper right, delete the default New Hard Disk and use the drop-down to select an Existing Hard Disk disk image:
- Ready to complete: Review the details and click Finish to create the image.
-
Select
Navigate to the VMs tab.
- From the list, select the VM you created.
- Click the Start button on the panel. A new window appears, showing the VM image loading.
- Log in with the credentials you created for the blueprint.
You can verify if the packages you added to the blueprint are installed. For example:
$ rpm -qa | grep firefox
With RHEL image builder, you can build a gce image, provide credentials for your user or GCP service account, and then upload the gce image directly to the GCP environment.
Set up a configuration file with credentials to upload your gce image to GCP by using the RHEL image builder CLI.
You cannot manually import gce image to Google Cloud, because the image will not boot. You must use either gcloud or RHEL image builder to upload it.
Prerequisites
You have a valid Google account and credentials to upload your image to 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. It is used to store the intermediate storage object of the image which is being uploaded. -
<gcp_storage_region>is both a regular Google storage region and a dual or multi-region. -
<object_key>is the name of an intermediate storage object. It must not exist before the upload, and it is deleted when the upload process is done. If the object name does not end with.tar.gz, the extension is automatically added to the object name. <gcp_credentials>is aBase64-encodedscheme of the credentials JSON file downloaded from Google Cloud. The credentials determine which project the Google Cloud uploads the image to.注意Specifying
<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
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 the GOOGLE_APPLICATION_CREDENTIALS environment variable is set, Application Default Credentials tries to load and use credentials from the file pointed to by the variable.
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.
注意You must use the Google Cloud credentials to determine which Google Cloud project to upload the image to. Therefore, unless you want to upload all of your images to the same Google Cloud project, you always must specify the credentials in the
gcp-config.tomlconfiguration file with theimage-buildercommand.
You can create custom images and automatically update them to the Oracle Cloud Infrastructure (OCI) instance by using RHEL image builder.
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 be granted security access in an OCI policy by your administrator.
-
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 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 to be uploaded.
- 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.
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 复制链接链接已复制到粘贴板!
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.
You can upload customized .ami images that you created by using RHEL image builder to the Alibaba Cloud.
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. You are redirected to a new window.
- Complete all the required information. See Creating an instance by using the custom launch for more details.
Click Create Instance and confirm the order.
注意You can see the option Create Order instead of Create Instance, depending on your subscription.
As a result, you have an active instance ready for deployment from the
Alibaba ECS Console.
21.2. Importing images to Alibaba Cloud 复制链接链接已复制到粘贴板!
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.
- On the left-side menu, click .
- On the upper right side, click . A dialog window opens.
Confirm that you have set up the correct region where the image is located. Enter the following information:
-
OSS Object Address: See how to obtain OSS Object Address. -
Image Name -
Operating System -
System Disk Size -
System Architecture -
Platform: Red Hat
-
Optional: Provide the following details:
-
Image Format:qcow2orami, depending on the uploaded image format. -
Image Description Add Images of Data DisksThe address can be determined in the OSS management console. After selecting the required bucket in the left menu:
-
- Select Files section.
Click the Details link on the right for the appropriate image.
A window appears on the right side of the screen, showing image details. The
OSSobject address is in theURLbox.Click .
注意The importing process time can vary depending on the image size.
The customized image is imported to the
ECSConsole.
21.3. Uploading customized RHEL images to Alibaba 复制链接链接已复制到粘贴板!
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 .
To deploy a customized RHEL image to the Alibaba Cloud, first, you must verify the customized image. The image needs a specific configuration to boot successfully, because Alibaba Cloud requests the custom images to meet certain requirements before you use them.
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 is displayed on 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.