Deploy the Ansible automation portal appliance on a RHEL 9 host with KVM using virt-install.
Before you begin
- A RHEL 9 host with KVM support (Intel VT-x or AMD-V enabled).
- An SSH key pair on the host.
- The Ansible automation portal QCOW2 disk image.
- Minimum 24 GB available memory on the host.
- Ansible Automation Platform administrator credentials (host URL, OAuth client ID and secret, and API token).
About this task
The following procedure provides example commands that you can adapt to your environment.
Procedure
-
Install the required packages and enable
libvirtd.
$ sudo dnf install -y qemu-kvm libvirt virt-install genisoimage
$ sudo systemctl enable --now libvirtd
-
Verify that KVM is available.
-
Ensure you have an SSH key pair to use in the cloud-init configuration.
If you do not have one, generate a key pair:
$ ssh-keygen -t ed25519 -N ""
-
Set environment variables for your deployment.
Replace the placeholder values. The examples in this procedure use automation-portal as the VM and project name. You can choose any name that suits your environment.
$ export QCOW2_PATH="/path/to/portal-appliance.qcow2"
$ export VM_NAME="automation-portal"
$ export VM_MEMORY=24576
$ export VM_CPUS=6
$ export WORK_DIR="$HOME/portal-deploy"
$ export IMAGE_DIR="/var/lib/libvirt/images"
$ mkdir -p "$WORK_DIR"
-
Create the cloud-init user-data configuration file and save it as $WORK_DIR/cloud-init-user-data.yaml.
Create a file named cloud-init-user-data.yaml in your working directory and populate it with your SSH key and Ansible Automation Platform credentials:
users:
- name: admin
sudo: ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- "<your-ssh-public-key>"
aap:
host_url: "https://<aap-host>"
token: "<aap-api-token>"
check_ssl: true
oauth:
client_id: "<oauth-client-id>"
client_secret: "<oauth-client-secret>"
database:
type: builtin
Replace the placeholder values in angle brackets with your SSH public key, Ansible Automation Platform URL, API token, and OAuth credentials.
Note For optional configuration settings such as external databases, custom ports, or SCM credentials, see
Cloud-init reference.
-
Create a cloud-init ISO from your user-data file.
KVM delivers cloud-init configuration to the VM as a small ISO disk image labeled cidata. Cloud-init expects two files on the ISO: user-data (your configuration) and meta-data (instance identity).
$ cd "$WORK_DIR"
$ cp cloud-init-user-data.yaml user-data
$ echo "instance-id: ${VM_NAME}" > meta-data
$ genisoimage -output cloud-init.iso -volid cidata -joliet -rock user-data meta-data
Note Cloud-init runs only once per instance ID. If you need to re-apply cloud-init configuration to an existing VM, change the instance-id value in the meta-data file to a new unique value, regenerate the ISO, and reattach it before rebooting.
-
Copy the disk image and create the VM.
$ sudo cp "$QCOW2_PATH" "$IMAGE_DIR/${VM_NAME}.qcow2"
$ sudo virt-install \
--name "$VM_NAME" \
--memory "$VM_MEMORY" \
--vcpus "$VM_CPUS" \
--disk "$IMAGE_DIR/${VM_NAME}.qcow2" \
--disk "$WORK_DIR/cloud-init.iso,device=cdrom" \
--osinfo rhel9-unknown \
--network default \
--noautoconsole \
--import
-
Wait 1-3 minutes for first-boot configuration to complete, then retrieve the VM IP address.
$ sudo virsh domifaddr "$VM_NAME"
Results
SSH into the Ansible automation portal RHEL appliance and confirm that all services are running:
$ ssh -i <private-key> <username>@<vm-ip>
$ sudo ansible-portal status
Example output for a healthy Ansible automation portal RHEL appliance:
portal.service - Automation portal
Active: active (running) since ...
postgres.service - PostgreSQL database
Active: active (running) since ...
devtools.service - Ansible development tools
Active: active (running) since ...
All three services should show active (running).
What to do next
Continue to Connect and verify Ansible automation portal to complete the post-installation steps.