Install Ansible automation portal on RHEL with KVM

Deploy the Ansible automation portal appliance on a RHEL 9 host with KVM using virt-install.

Before you begin

About this task

The following procedure provides example commands that you can adapt to your environment.

Procedure

  1. Install the required packages and enable libvirtd.
    $ sudo dnf install -y qemu-kvm libvirt virt-install genisoimage
    $ sudo systemctl enable --now libvirtd
  2. Verify that KVM is available.
    $ lsmod | grep kvm
  3. 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 ""
  4. 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"
  5. Save your cloud-init user-data file as $WORK_DIR/cloud-init-user-data.yaml.
  6. 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
  7. 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
  8. 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 systemctl status portal postgres devtools

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.

Remove the VM

Delete the VM and its storage after an evaluation.

About this task

To delete the VM and its storage after an evaluation, run the following commands.

Procedure

Destroy the VM, remove its definition and storage, and clean up the working directory.
$ sudo virsh destroy "$VM_NAME"
$ sudo virsh undefine "$VM_NAME" --remove-all-storage
$ rm -rf "$WORK_DIR"