Chapter 10. Creating RHEL for Edge AMI images
Chapter 10. Creating RHEL for Edge AMI images You can create a RHEL for Edge edge-ami customized image by using RHEL image builder. The RHEL for Edge edge-ami has Ignition support to inject the user configuration into the images at an early stage of the boot process. Then, you can upload the image to AWS cloud and launch an EC2 instance in AWS. You can use the AMI image type on AMD or Intel 64-bit architectures. 10.1. Creating a blueprint for Edge AMI images Create a blueprint for the edge-ami image and customize it with the customizations.ignition section. With that, you can create your image and when booting the image, inject the user configuration. Prerequisites You have created an Ignition configuration file. For example: For more details, see Creating an Ignition configuration file . Procedure Create a blueprint in the Tom's Obvious, Minimal Language (TOML) format, with the following content: Where: The name is the name and description is the description for your blueprint. The version is the version number according to the Semantic Versioning scheme. The modules and packages describe the package name and matching version glob to be installed into the image. For example, the package name = "open-vm-tools" . Notice that currently there are no differences between packages and modules. The groups are packages groups to be installed into the image. For example groups = "wheel" . If you do not know the modules and groups, leave them empty. The customizations.user creates a username and password to log in to the VM. The customizations.ignition.firstboot contains the URL where the Ignition configuration file is being served. Note By default, the open-vm-tools package is not included in the edge-vsphere image. If you need this package, you must include it in the blueprint customization. Import the blueprint to the image builder server: List the existing blueprints to check whether the created blueprint is successfully pushed and exists: Check whether the components and versions listed in the blueprint and their dependencies are valid: steps Use the blueprint you created to build your edge-ami image. 10.2. Creating a RHEL for Edge AMI image Create a RHEL for Edge edge-ami image in the RHEL image builder command-line interface. Prerequisites You created a blueprint for the edge-ami image. You served an OSTree repository of the commit to embed it in the image. For example, http://10.0.2.2:8080/repo . For more details, see Setting up a web server to install RHEL for Edge image . Procedure Start the compose of a edge-ami image: The -- <ostree repo url> is the URL of your repo, for example: http://10.88.0.1:8080/{ <blueprint-name> }/repo . A confirmation that the composer process has been added to the queue appears. It also shows a Universally Unique Identifier (UUID) number for the image created. Use the UUID number to track your build. Also, keep the UUID number handy for further tasks. Check the image compose status: The output displays the status in the following format: After the compose process finishes, download the resulting image file: steps Upload the edge-ami image to AWS 10.3. Uploading a RHEL Edge AMI image to AWS Upload the edge-ami image to Amazon AWS Cloud service provider by using the CLI. Prerequisites You have an Access Key ID configured in the AWS IAM account manager. You have a writable S3 bucket prepared. You have created the required roles for your AWS bucket. You have the aws-cli tool installed . Procedure Configure the aws-cli tool: Configure your profile. Run the command and enter your Access key ID credential, Secret access key, Default region name, and default output name: List the existing buckets: Upload your image to S3: List the image in the S3 bucket: Create a container-simple.json file. Replace the "URL" content with the S3 bucket. For example: s3://rhel-edge-ami-us-west-2/2ba3c125-cc58-4cc0-861a-4cc78e892df6-image.raw . Import the edge.ami image to the S3 bucket as an EC2 snapshot. Note The EC2 image must be in the same region that you have created the S3 bucket. The following . json is an example of the command output: Take note of "ImportTaskId" value from the .json file. Use it to check the import status. In this example, the "ImportTaskId" is import-snap-0f3055c4b7a454c85 . Check the import status of the snapshot, by using the "ImportTaskId" value from the output .json file from the step: Run this command until the "Status" is marked as "completed". Register the edge.ami image to be able to launch an instance from the image. If you do not specify an architecture, it defaults to the i386 architecture. After registering the image, you can access EC2 to create the AMI image from the snapshot, and launch it. Verification To confirm that the image upload was successful: Access EC2 in the menu and select the correct region in the AWS console. The image must have the available status, to indicate that it was successfully uploaded. On the dashboard, select your image and click Launch. When launching the new instance, you must select UEFI as the boot mode, and choose at least 4GB of RAM for the EC2 image. You can log in into the edge-ami on AWS by using the username and password you created with the Ignition configuration. Additional resources Required service role to import a VM
{ "ignition":{ "version":"3.3.0" }, "passwd":{ "users":[ { "groups":[ "wheel" ], "name":"core", "passwordHash":"USD6USDjfuNnO9t1Bv7N" } ] } } name = "ami-edge-image" description = "Blueprint for Edge AMI image" version = "0.0.1" packages = ["cloud-init"] modules = [] groups = [] distro = "" [[customizations.user]] name = "admin" password = "admin" groups = ["wheel"] [customizations.ignition.firstboot] url = http:// <IP_address> :8080/ config.ig composer-cli blueprints push <blueprint-name> .toml composer-cli blueprints show <blueprint-name> composer-cli blueprints depsolve <blueprint-name> composer-cli compose start-ostree <blueprint-name> edge-ami -ref rhel/9/x86_64/edge --url <ostree repo url> composer-cli compose status <UUID> RUNNING date <blueprint-name> <blueprint-version> edge-ami composer-cli compose image <UUID> aws configure aws configure --profile aws s3 ls aws s3 cp <path_to_image/image> s3:// <your_bucket_name> aws s3 ls s3:// <your_bucket_name> { "Description": "RHEL for Edge image", "Format": "edge-ami", "Url": "s3://rhel-edge-ami-us-west-2/UUID-image.raw" } aws ec2 import-snapshot --description "RHEL edge" \ --disk-container file://container-simple.json --region us-west-2 { "Description": "RHEL for Edge image", "Format": "edge-ami", "Url": "s3://rhel-edge-ami-us-west-2/UUID-image.raw" } aws ec2 describe-import-snapshot-tasks --import-task-ids import-snap-0f3055c4b7a454c85 { "ImportSnapshotTasks": [ { "Description": "RHEL edge", "ImportTaskId": "import-snap-0f3055c4b7a454c85", "SnapshotTaskDetail": { "Description": "RHEL edge", "DiskImageSize": 10737418240.0, "Format": "RAW", "SnapshotId": "snap-001b267e752039eab", "Status": "completed", "Url": "s3://rhel-edge-ami-us-west-2/2ba3c125-cc58-4cc0-861a-4cc78e892df6-image.raw", "UserBucket": { "S3Bucket": "rhel-edge-ami-us-west-2", "S3Key": "2ba3c125-cc58-4cc0-861a-4cc78e892df6-image.raw" } }, "Tags": [] } ] } aws ec2 register-image \ --name ami-edge-name -ami-x86" \ --architecture <architecture> \ --tag-specifications 'ResourceType=image,Tags=\\\{Key=Name,Value={{ blueprint_name }}-ami-x86}' \ --root-device-name /dev/sda1 \ --block-device-mappings DeviceName=/dev/sda1,Ebs={SnapshotId={{ snapshot_id }}} DeviceName=/dev/sdh,Ebs={VolumeSize=10} \ --boot-mode uefi-preferred --query="ImageId" --output=text \ --region="{{ aws_region }}" i