Installing and Running Ansible AWX on Kubernetes: A Step-by-Step Guide

Are you looking to streamline your IT automation workflows with Ansible AWX on Kubernetes? Ansible AWX, the open-source version of Ansible Tower, offers a powerful web-based interface for managing Ansible playbooks, inventories, and schedules. Pairing it with Kubernetes, a leading container orchestration platform, provides scalability, resilience, and ease of deployment. In this guide, we’ll walk you through installing and running Ansible AWX on Kubernetes, optimized for beginners and seasoned DevOps professionals alike.

What is Ansible AWX?

Ansible AWX is an open-source automation platform that simplifies managing complex IT tasks using Ansible. It provides a user-friendly dashboard, REST API, and role-based access control (RBAC), making it ideal for teams managing infrastructure at scale. Running AWX on Kubernetes leverages the containerized environment for high availability and efficient resource utilization.

Why Run Ansible AWX on Kubernetes?

  • Scalability: Kubernetes dynamically scales AWX components based on demand.
  • Reliability: Built-in self-healing ensures AWX stays operational.
  • Portability: Deploy AWX across cloud providers or on-premises with ease.

Prerequisites for Installing Ansible AWX on Kubernetes

Before diving in, ensure you have the following:

  1. A Kubernetes Cluster: A running cluster (e.g., K3d, Minikube for testing or a production-grade cluster like EKS, GKE, or AKS).
  2. kubectl: Installed and configured to interact with your cluster.
  3. Helm: The Kubernetes package manager for simplified deployment.
  4. Git: To clone the AWX repository.
  5. Basic Ansible Knowledge: Familiarity with playbooks and inventories.
  6. Storage: Persistent storage for PostgreSQL (AWX’s database).

Let’s get started!

Step-by-Step Guide to Install Ansible AWX on Kubernetes

Step 1: Set Up Your Kubernetes Cluster

If you don’t have a Kubernetes cluster, you can set up a local one using K3d with ingress:

k3d cluster create --api-port 6550 -p "80:80@loadbalancer" --agents 2

For production, use a managed service like Amazon EKS or Google Kubernetes Engine. Verify your cluster is running:

kubectl get nodes

Step 2: Install Helm

Helm simplifies deploying AWX. Install it using your package manager.

From Homebrew (macOS)

brew install helm

From Script

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

Step 3: Clone Repository

Add the official AWX Helm chart repository to your Helm configuration:

git clone https://github.com/ansible/awx-operator.git
cd awx-operator
git tag
git checkout tags/2.19.1
export VERSION=2.19.1

Step 4: Customize AWX Deployment

Create a values.yaml file to configure AWX settings, such as persistent storage and admin credentials. Here’s a basic example:

nano kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  # Find the latest tag here: https://github.com/ansible/awx-operator/releases
  - github.com/ansible/awx-operator/config/default?ref=2.19.1
  - awx-demo.yml

# Set the image tags to match the git version from above
images:
  - name: quay.io/ansible/awx-operator
    newTag: 2.19.1

# Specify a custom namespace in which to install AWX
namespace: awx

Step 5: Deploy AWX on Kubernetes

Install the manifests by running this:

kubectl apply -k .

Wait for the pods to start:

kubectl get pods -n awx

Step 6: Access the AWX Web Interface

Expose the AWX service to access it locally or externally.

nano awx-ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: awx-ingress
  namespace: awx
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: ansible-awx.devopstips.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: awx-demo-service
            port:
              number: 80

Open your browser and navigate to ansible-awx.devopstips.local.

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

Running Ansible AWX on Kubernetes: Post-Installation Tips

1. Verify Deployment Health

Check the status of AWX components:

kubectl get deployments -n awx
kubectl get svc -n awx

Ensure the PostgreSQL, AWX web, and task pods are running.

2. Create Your First Project

Log into AWX, navigate to “Projects,” and link a Git repository containing your Ansible playbooks. AWX will sync and execute them as needed.


Troubleshooting Common Issues

  • Pods Not Starting: Check logs with kubectl logs <pod-name> -n awx to diagnose errors like missing storage or misconfiguration.
  • Service Unreachable: Verify the service is running (kubectl get svc -n awx) and port-forwarding is correctly set up.
  • Login Issues: Ensure the admin credentials match those in values.yaml.

Benefits of Running Ansible AWX on Kubernetes

Deploying AWX on Kubernetes unlocks:

  • Automation at Scale: Manage thousands of nodes effortlessly.
  • Team Collaboration: RBAC and workflows enhance teamwork.
  • Cost Efficiency: Optimize resource usage with Kubernetes.

Conclusion

Installing and running Ansible AWX on Kubernetes combines the power of automation with container orchestration, delivering a robust solution for modern IT environments. By following this guide, you’ve set up AWX, accessed its web interface, and prepared it for real-world tasks. Ready to automate your infrastructure? Start exploring AWX’s features today!

For more advanced configurations, check the official AWX documentation or join the Ansible community for support.


Video Tutorial: Installing Ansible AWX on Kubernetes

For a detailed video walkthrough, check out our YouTube tutorial:

Leave a Reply

Your email address will not be published. Required fields are marked *