Skip to the stories
Windows & PowerShell

Deploy AWX with VCF Automation 9.1 and Run Jobs on New VMs

By Mayank Goyal 362 views

A VCF Automation 9.1.1 lab build pairs AWX 24.6.1 with cloud templates to provision the server, add the integration and run jobs on new VMs.

Deploy AWX with VCF Automation 9.1 and Run Jobs on New VMs

VCF Automation can provision a virtual machine and then call AWX to run a job against it. The practical value is the handoff: a deployment can add its new VM to an AWX inventory and start a job template with that machine as the limit, without an administrator adding the host by hand.

VCF Automation deployment LAB-awx01 Overview tab listing the AWX server VM name, hostname, size, IP address, AWX UI and API links, operator version and SSH login

This lab setup uses two cloud templates. The first turns an Ubuntu VM into an AWX server; the second deploys a test VM and runs an AWX job against it. Between them, an Ansible Automation Platform integration connects VCF Automation to AWX. The build was tested on VCF Automation 9.1.1 in a VM Apps organisation, with embedded VCF Operations Orchestrator 9.1.1, build 25643527, deploying to vSphere 9.

The tested software versions were Ubuntu 24.04, AWX 24.6.1, AWX Operator 2.19.1 and k3s v1.37.2+k3s1. The Ubuntu VM template had cloud-init and open-vm-tools installed. Those prerequisites matter: cloud-init handles the guest configuration, while VMware Tools provides a way to publish installation progress to the VM's guestinfo data.

Plan the lab inputs

Before deploying, prepare a network with a capability tag such as net:lab-vm-mgmt, and reserve a free address for the AWX VM. The guest needs internet access to retrieve k3s from get.k3s.io, operator manifests from GitHub and container images from quay.io. AWX is configured with at least 4 vCPU and 8 GB of memory.

The template accepts CPU and memory as direct inputs, so it doesn't need a flavor mapping. It also accepts the name of a vCenter VM template through imageRef, without an image mapping. The default template, ubuntu24_template, should include cloud-init and open-vm-tools.

There's another option for imageRef: provide the Ubuntu 24.04 cloud image OVA URL directly. In that case, VCF Automation downloads the OVA for each request, so the deployment environment needs HTTPS access to cloud-images.ubuntu.com. In this lab, the URL-based deployment took about a minute longer than the deployment from the vCenter template.

# Existing vCenter VM template
imageRef: ubuntu24_template

# Ubuntu 24.04 cloud image OVA
imageRef: https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.ova
VCF Automation template editor showing the LAB - AWX - Ubuntu cloud template with an awxServer machine on an awxNetwork and its YAML

The AWX template exposes the values most likely to vary between deployments. Its defaults include vmName set to lab-awx01, awxFqdn set to awx.vmw.lab, and imageRef set to ubuntu24_template. VM sizing defaults are 4 CPUs, 8 GB of memory and a 60 GB boot disk; the root disk is expanded during first boot.

Network inputs include a required static IPv4 address, a default prefix length of 24, and a default gateway of 10.20.44.1. DNS defaults are 10.20.44.11 and 10.20.44.12, with vmw.lab as the search domain. The default NTP servers are the same two addresses. Other inputs include the AWX Operator version, defaulting to 2.19.1; an encrypted AWX admin password; and an operating system login, defaulting to awxadmin, with an encrypted password.

What the first boot does

Cloud-init writes five scripts to /usr/local/sbin and runs them in sequence. The first creates the operating system login. That order is useful when troubleshooting: if a later install step stops, the administrator can still SSH into the VM and inspect the logs.

runcmd:
 - [ /usr/local/sbin/add-login-user.sh, "${input.osUsername}", "${input.osPassword}" ]
 - [ sh, -c, "systemctl restart ssh 2>/dev/null || systemctl restart sshd 2>/dev/null || true" ]
 - [ /usr/local/sbin/set-static-ip.sh ]
 - [ /usr/local/sbin/set-ntp-and-disk.sh ]
 - [ /usr/local/sbin/install-awx.sh ]
 - [ sh, -c, "echo \"cloud-init done $(date)\" > /var/log/cloudinit-done.log" ]

The scripts configure the static address, DNS and NTP, expand the root disk, and install the AWX components. The main installer sets up k3s, the AWX Operator and the AWX instance, then performs a basic readiness check. The larger disk gives container images and the AWX database room to grow.

Track installation and check AWX

VCF Automation marks the deployment complete when the VM is up, but the software installation continues inside the guest for about 10 minutes. Each installation step is written to /var/log/awx-install.log and sent through VMware Tools to guestinfo.awx.status. Administrators can inspect that value in the VM's advanced settings in vCenter, or retrieve it from Orchestrator.

The sample status script searches for a VM whose name begins with lab-awx01, reads its guestinfo value and logs the VM name, guest IP address and current status:

var vm = VcPlugin.getAllVirtualMachines(null, "xpath:matches(name,'lab-awx01.*')")[0];
var status = null;
var extraConfig = vm.config.extraConfig;
for (var i = 0; i < extraConfig.length; i++) {
 if (extraConfig[i].key == "guestinfo.awx.status") {
  status = "" + extraConfig[i].value;
 }
}
System.log(vm.name + " (" + vm.guest.ipAddress + "): " + status);

One test deployment reported AWX 24.6.1 ready at both https://10.20.44.70/ and https://awx.vmw.lab/. Its status also showed a warning that the admin login check had failed because DNS was not registered. AWX was working; the warning came from an earlier version of the template that didn't retry the login check. The DNS server had refused the automatic update, so the administrator needed to add the A record manually or use the IP address.

The installation log showed the login user and network ready first, followed by NTP and disk setup. It then recorded k3s installation, the operator starting, AWX instance creation, and a wait for pods and database migrations. In the recorded run, the final ready status appeared at 17:52:51 after the process began at 17:46:07.

On the VM, check that the AWX pods are running or have completed their migration:

kubectl -n awx get pods

The expected example included a completed AWX migration pod, a running operator, a running PostgreSQL pod, and running AWX task and web pods. Then check the API version through the IP address:

curl -sk https://10.20.44.70/api/v2/ping/ | jq -r .version

For this build, the response was 24.6.1. The web interface is available at https://<AWX IP or FQDN>/. The template creates a self-signed certificate, which the browser will flag; the lab instructions accept it before signing in as admin with the password supplied as awxAdminPassword.

AWX 24.6.1 dashboard after login, showing hosts, projects and inventories, the job activity chart and recent VCFA - Hello World jobs

Connect AWX to VCF Automation

In VCF Automation, open Infrastructure > Connections > Integrations, select Add Integration and choose Ansible Automation Platform. Enter the AWX hostname or IP address without a protocol prefix or port. For example, use awx.vmw.lab or 10.20.44.70, not an address beginning with https://.

Supply the AWX admin credentials, or use an AWX account that can run the job templates required by the cloud templates. Select Validate and accept the self-signed AWX certificate shown during validation. Name and save the integration; cloud templates refer to it by that name. The lab names it LAB-AWX-Lab.

VCF Automation Infrastructure Integrations page with the embedded Orchestrator and the new LAB-AWX-Lab Ansible Tower integration at 10.20.44.70
Details of the LAB-AWX-Lab Ansible Tower integration in VCF Automation with hostname 10.20.44.70 and username admin

The same integration can be created through the IaaS API. Its integration type is ansible.tower. A validate-only request uses POST /iaas/api/integrations?apiVersion=2021-07-15&validateOnly=true, with the integration name, credentials, hostname and data centre ID in the body. For this lab, those values are LAB-AWX-Lab, the AWX admin account, host 10.20.44.70 and onprem.

When VCF Automation encounters the self-signed certificate, the validation tracker returns UNTRUSTED_CERTIFICATE and a certificate resource path. Retrieve that resource with the API, check that the certificate belongs to the AWX server, and include its value in the request's certificateInfo property. Run the integration POST again without validateOnly to create the integration. The API example uses the same apiVersion=2021-07-15 value.

Set up the AWX objects

VCF Automation can add each deployed VM to an existing AWX inventory and launch a named job template. AWX therefore needs an inventory, a machine credential that can SSH to the VM, and a job template with Prompt on launch enabled for Limit. The inventory must already exist; VCF Automation creates the host entries.

The lab uses AWX's built-in Demo Project and its hello_world.yml playbook. An AWX API script creates or reuses an inventory named VCFA Deployments, a machine credential named VCFA Lab VM Login, and a job template named VCFA - Hello World. The job template points to the Demo Project and playbook, and sets ask_limit_on_launch to true. Reusing existing objects makes the script safe to run again without creating duplicates.

Run the script from a Linux machine that can reach AWX and has curl and jq. The AWX VM is a convenient place because the template installs both tools. Before running it, set the AWX address and admin password, plus the VM username and password that cloud-init will create on each test machine. Those VM login values must match the credentials supplied to AWX.

ssh [email protected]
nano awx-setup-vcfa.sh
bash awx-setup-vcfa.sh

The script syncs the Demo Project from GitHub and waits for its status before building the AWX objects. In the example output, the sync succeeded, and AWX returned IDs for the inventory, credential and job template. The final check showed hello_world.yml, ask_limit_on_launch=true and the expected machine credential.

A password-based machine credential keeps this lab straightforward. For a deployment beyond a lab, the source configuration recommends an SSH key for the machine credential.

Run an AWX job as part of deployment

The second cloud template deploys an Ubuntu VM with a static IP and an ansible sudo user. A Cloud.Ansible.Tower resource connects the VM to the AWX integration and selects the job template:

awxJob:
  type: Cloud.Ansible.Tower
  properties:
    account: ${input.awxAccount}
    host: ${resource.ansibleVm.*}
    hostName: ${input.vmName}
    inventoryName: ${input.awxInventory}
    hostVariables: |
      ansible_host: ${input.ipAddress}
    maxConnectionRetries: 10
    maxJobRetries: 3
    templates:
      provision:
        - name: ${input.awxJobTemplate}
          type: job

account names the integration, and host binds the AWX resource to the VM so the job runs after that machine is created. hostName becomes the AWX inventory host name and supplies the job's limit. The hostVariables value must remain a YAML string, with the pipe character shown above; Broadcom documents this requirement in KB 436313. The ansible_host variable directs AWX to the VM's static address. The template allows up to 10 connection retries and 3 job retries.

VCF Automation template editor showing the LAB - Ansible Hello World - Ubuntu template with an ansibleNetwork and an awxJob Ansible Tower resource

A successful deployment has three resources in its topology: the network, the VM and the AWX job. The deployment history shows the vSphere machine completing before the Cloud.Ansible.Tower resource. In the test run, the AWX job finished about 40 seconds after the VM.

Topology of the LAB-ansible02 deployment in VCF Automation with the ansibleVm machine, its network and the awxJob Ansible Tower resource
History tab of the LAB-ansible02 deployment showing the vSphere machine finishing first and the Cloud.Ansible.Tower awxJob resource finishing afterwards

On the AWX side, the example VM lab-ansible02 appeared in the VCFA Deployments inventory with ansible_host: 10.20.44.83. Job 13, named VCFA - Hello World, completed successfully with its limit set to lab-ansible02 and admin as the launching account. The play gathered facts and returned the message Hello World!; the recap showed two successful tasks, zero changes and no unreachable or failed hosts.

AWX job output page for VCFA - Hello World showing a successful run on lab-ansible02 with the Hello World! message and the play recap

Version and installation considerations

The AWX deployment method in this lab differs from older AWX and vRA 8 setups that used the Docker Compose installer. That installer is no longer available for current AWX releases: AWX 18 and later installs through the AWX Operator on Kubernetes. For a lab, the setup here runs single-node k3s on the same VM.

Compatibility with the endpoint matters. AWX 24.6.1 provides the /api/v2/ path expected by the VCF Automation integration. Ansible Automation Platform 2.5 moved that API path, and Broadcom documents that the integration doesn't work with it in KB 394498.

Three implementation details are easy to miss: the AWX Operator's kustomization needs an override for the kube-rbac-proxy image or the operator pod won't start; VCF Automation calls Tower over HTTPS on port 443, which k3s Traefik provides by hostname and IP; and the API integration type is ansible.tower. A self-signed certificate can be accepted by returning it in certificateInfo.

The templates, guest scripts, AWX setup script and Orchestrator status script are available in the awx-vcfa GitHub folder. The cloud templates are lab-awx-ubuntu.yaml and lab-ansible-hello-world-ubuntu.yaml. The guest scripts are under guest-scripts; the AWX API setup script is awx-setup-vcfa.sh, and the Orchestrator example is getAwxInstallStatus.js.

For administrators, the end-to-end check is the useful milestone: confirm the VM is reachable, verify AWX's API and pods, add the integration, prepare the inventory and credential, then deploy the test template and inspect the job limit and result. Once that chain works, replacing the demonstration playbook with a task from a Git repository is the next step.

Source: Mayank Goyal · cloudblogger.co.in

From the same basket