Testing frameworks for images built via Red Hat Insights image builder

Building images for cloud deployments or on-premises servers provides a number of challenges. In this learning path by Gianluca Zuccarelli and Obinna Ezeakachi, we’ll explore how to use Red Hat Insights image builder to deploy pre-hardened images then monitor the systems with our compliance tool.

Building images for cloud deployments or on-premises servers provides a number of challenges. In this learning path by Gianluca Zuccarelli and Obinna Ezeakachi, we’ll explore how to use Red Hat Insights image builder to deploy pre-hardened images then monitor the systems with our compliance tool.

Creating images using OpenSCAP via Red Hat Insights image builder

12 mins

Red Hat® Insights image builder makes the process of hardening images much simpler since it is able to leverage OpenSCAP remediations at build time before the image has even been launched. This is desirable since some options, such as filesystem customizations, are hard to remediate once an image has been built and booted. Let’s get started by walking through how to create images using OpenSCAP via Red Hat Insights image builder. 

What will you learn?

  • Building images with Insights image builder using OpenSCAP via the UI
  • Building images with Insights image builder using the API

What do you need before starting?

  • Cloud service provider account credentials
  • Red Hat account

Building images with Insights image builder

There are two ways we can build images using image builder in the console. The first way is making an API request to the backend image builder application and then deploying the resulting image to AWS. Alternatively, we can use the front end to build pre-hardened images. This guide will take you through both methods.

Building images using OpenSCAP via the UI

Since April 2024, it is possible to build pre-hardened images using OpenSCAP in the console environment. To get started building an image, navigate to Image Builder. and click on the Create Image button. We will skip ahead a few steps through the wizard with the following assumptions:

  • A RHEL 9 image was selected
  • An AWS Amazon Machine Image (AMI) was selected as the target environment
  • The system was registered with an Access Key

From the OpenSCAP compliance step, choose an OpenSCAP profile from the dropdown menu, and select the “PCI-DSS” profile:

 

Insights screenshot of OpenSCAP step
Insights screenshot highlighting OpenSCAP step in image builder wizard

 

The “PCI-DSS” doesn’t have any partitioning requirements. For profiles that do have required partitions, the filesystem step in the wizard will be pre-populated with recommended partition sizes based on the requirements of the selected profile. These sizes can be amended. Additional mount points can also be added.

 

Screenshot of customization step
Filesystem customization step in the image builder wizard

 

Similarly, the required packages for the selected profile are pre-populated; these packages may be removed, and additional packages can be added, as desired. 

Note that amending the suggested file system layout or removing suggested packages may impact your image’s compliance score.


 

Screenshot of package selection
Auto-generated package selection in the package selection step of the image builder wizard

 

Click through the remaining steps, select the options as desired, then start the image build. Once the build is complete, we can launch the image and move on to the next step.

Building images via the API

To start off with, we will build an image for AWS using the Insights image builder’s API. First, navigate to the operation to compose an image in the console.

 

Screenshot of OpenAPI page
The OpenAPI page for creating a compose request via the image builder API

 

Scroll down to the compose image section, click on the Try it out button, and input the following JSON script. Amend the following values as you see fit: 

  • distribution
  • image_name
  • architecture
  • image_type
  • type, share_with_accounts
  • profile_id

 

```bash
{
  "distribution": "rhel-92",
  "image_name": "obi",
  "image_requests": [
    {
      "architecture": "x86_64",
      "image_type": "ami",
      "upload_request": {
        "type": "aws",
        "options": {
          "share_with_accounts": [ "AWS_Account_ID" ]
        }
      }
    }
  ],
  "customizations": {
    "packages": [ "zsh" ],
    "openscap": {
      "profile_id": "xccdf_org.ssgproject.content_profile_pci-dss"
    }
  }
}
```

 

Example post request
Example post request for creating an image via the image builder API

 

Then hit the Execute button to build the image. Head to https://console.redhat.com/insights/image-builder and monitor the build process for the AMI. The AMI will be ready to use once you see the green tick and ready message. 

To share to AWS, click on the three dots in the right corner of the screen and click the option, Share to new region. Choose the region in which you want to raise your AMI. 

 

Screenshot of monitoring screen
Monitoring the build status of an image in the Insights image builder images table

 

Screenshot of share screen
Sharing an image to a new region in AWS via the Insights image builder tool

 

With this done, you’re ready to learn about compliance monitoring and testing frameworks in the next resource.

Previous resource
Prerequisites
Next resource
Testing frameworks

This learning path is for operations teams or system administrators

Developers might want to check out Testing frameworks for images built via Insights image builder on developers.redhat.com. 

Get started on developers.redhat.com

Hybrid Cloud Logo LinkedIn YouTube Facebook Twitter

Products

Tools

Try, buy, sell

Communicate

About Red Hat

We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.