Introduction

Automation is a game-changer in modern infrastructure management, and AWX—the open-source version of Ansible Tower—provides a powerful web-based interface to manage Ansible playbooks and workflows efficiently. This Proof of Concept (PoC) aims to demonstrate how AWX can be set up, configured, and leveraged for automated infrastructure provisioning.

Objectives

In this PoC, we’ll cover:

  • Setting up AWX on a local server or virtualized environment.
  • Integrating AWX with Ansible to automate infrastructure tasks.
  • Exploring workflows and job templates to streamline automation.

Setting Up AWX

Prerequisites

Before diving into AWX installation, ensure you have the following:

  • A Linux-based system (I used Rocky 8)
  • Sufficient system resources (CPU, memory, disk space)

Installation Prerequisites

Update system
sudo dnf -y updatesudo reboot
Install tools
sudo yum install git jq make -y
Install k3s
sudo -i
curl -sfL https://get.k3s.io | sh -
Add /usr/local/bin to path
vi ~/.bashrc 

Add the following line

 export PATH=$PATH:/usr/local/bin
Load the file
source ~/.bashrc
Add firewall rules and reboot
firewall-cmd --permanent --add-port=6443/tcp
firewall-cmd --permanent --zone=trusted --add-source=10.42.0.0/16 
firewall-cmd --permanent --zone=trusted --add-source=10.43.0.0/16
firewall-cmd --reload

# Reboot
reboot
Check status
sudo -i
systemctl status k3s
kubectl version --client

Install AWX

Clone AWX Operator repository
git clone https://github.com/ansible/awx-operator.git
cd awx-operator
Checkout the tag for the version you want to install (i.e. 2.19.1)
git checkout tags/2.19.1
Set the namespace of where you want to deploy it in k3s
export NAMESPACE=awx
Deploy the AWX Operator
make deploy
Install the manifest
cd config/manager/
kubectl apply -k .

Wait a bit and you should see AWX running

kubectl get pods -n awx
NAME                                               READY   STATUS    RESTARTS   AGE
awx-operator-controller-manager-66ccd8f997-rhd4z   2/2     Running   0          11s
Set the context of the namespace to awx so we can mitegate the –namespace tag in future kubectl requests
kubectl config set-context --current --namespace=awx
Deploy AWX

Next, create a file named awx-demo.yml in the same folder with the suggested content below. The metadata.name you provide will be the name of the resulting AWX deployment.

vi awx-demo.yml

Add the following

---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx-demo
spec:
  service_type: nodeport

Add the aws-demo.yml to kustomization.yaml

vi kustomization.yaml 

Update like below

...
resources:
  - manager.yaml
  # Add this extra line:
  - awx-demo.yml
...

Apply the changes

kubectl apply -k .

After a few seconds (or longer) you should see the deployment

$ kubectl get pods -l "app.kubernetes.io/managed-by=awx-operator"
NAME                        READY   STATUS    RESTARTS   AGE
awx-demo-77d96f88d5-pnhr8   4/4     Running   0          3m24s
awx-demo-postgres-0         1/1     Running   0          3m34s

$ kubectl get svc -l "app.kubernetes.io/managed-by=awx-operator"
NAME                TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
awx-demo-postgres   ClusterIP   None           <none>        5432/TCP       4m4s
awx-demo-service    NodePort    10.109.40.38   <none>        80:31006/TCP   3m56s

After a few minutes, the new AWX instance will be deployed. You can look at the operator pod logs in order to know where the installation process is at:

kubectl logs -f deployments/awx-operator-controller-manager -c awx-manager

Once deployed, your AWX instance should now be reachable at http://localhost:<assigned-nodeport>/ (in this case, http://localhost:31006/).

By default, the admin user is admin and the password is available in the -admin-password secret. To retrieve the admin password, run

kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 --decode ; echo

Creating Job Templates

AWX simplifies Ansible automation by allowing users to define job templates. Here’s how you can create one:

  1. Navigate to Templates > Add Job Template.
  2. Define the playbook path and execution environment.
  3. Set credentials for target hosts.
  4. Run the job to verify playbook execution.

Exploring Workflow Automation

Workflows in AWX allow chaining multiple job templates together for complex automation scenarios. You can define approval steps, condition-based execution, and more to enhance orchestration.

Conclusion

With AWX, managing Ansible automation becomes seamless, allowing efficient deployment, monitoring, and scaling. This PoC is just the beginning—once set up, the possibilities for automation are endless!

Leave a Reply

Discover more from Jamie Nicholls

Subscribe now to keep reading and get access to the full archive.

Continue reading