Hello Geeks, I hope you are aware about Ansible AWX, if not then Ansible AWX is a Web based GUI tool for managing ansible playbooks. There are lot of other features of AWX apart from execution of Ansible playbooks like source management integration, logging RBAC and more.

In other words, we can say Ansible AWX is considered as an upstream project of Red HAT Ansible Tower. From AWX version 18.x and onwards, installation focus is moved from docker to Kubernetes. So, in this article, we will cover the step by step Ansible AWX Installation on Kubernetes Minikube.

I am assuming Minikube is already installed on your Linux system. If not, then use below URL:

  • How to Install Minikube on Ubuntu 20.04 LTS / 21.04

Note: Make sure you start your minikube cluster with enough resources (at least 4 vCPU and 8 GB RAM) , in my case I have started minikube with following resources and options.

$ minikube start --addons=ingress --cpus=4 --cni=flannel --install-addons=true --kubernetes-version=stable --memory=8g

Verify the Minikube Cluster Installation

Run following commands to verify the minikube installation and cluster status,

$ minikube status
$ kubectl cluster-info
$ kubectl get nodes

Output of above commands should look like below:

Minikube-Installation-Cluster-Check

Perfect, above confirms that minikube has been installed and started successfully. Let’s move to AWX installation steps.

Step 1) Install AWX Operator

To install AWX operator, execute the following kubectl command,

$ kubectl apply -f https://raw.githubusercontent.com/ansible/awx-operator/0.12.0/deploy/awx-operator.yaml

Output

Install-AWX-Operator-kubectl-command

Run below command to confirm whether AWX operator’s pod is started or not. If not started then wait for couple of minutes as it takes time,

devops@linuxtechi:~$ kubectl get pods
NAME                           READY   STATUS    RESTARTS   AGE
awx-operator-79bc95f78-pb7tz   1/1     Running   0          5m23s
devops@linuxtechi:~$

Step 2) Create AWX Instance yaml file

Create ansible-awx.yml file with the following contents

$ vi ansible-awx.yml
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: ansible-awx
spec:
  service_type: nodeport
  ingress_type: none
  hostname: ansible-awx.example.com

save and quit the file.

Step 3) Deploy Ansible AWX Instance

Now, let’s deploy AWX instance in our cluster by executing below command,

devops@linuxtechi:~$ kubectl apply -f ansible-awx.yml
awx.awx.ansible.com/ansible-awx created
devops@linuxtechi:~$

Above will create a deployment with a name ’ansible-awx’ and this deployment will have two pods and services.

After couple of minutes, Ansible AWX will be deployed and in case you wish to monitor installation logs then use below command,

$ kubectl logs -f deployment/awx-operator

Run below command to verify the status of AWX Pods,

devops@linuxtechi:~$ kubectl get pods -l "app.kubernetes.io/managed-by=awx-operator"
NAME                           READY   STATUS    RESTARTS   AGE
ansible-awx-5ddfccf664-vrdq2   4/4     Running   0          7m40s
ansible-awx-postgres-0         1/1     Running   0          8m24s
devops@linuxtechi:~$

Run following command to view the service status,

devops@linuxtechi:~$ kubectl get svc -l "app.kubernetes.io/managed-by=awx-operator"
NAME                   TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
ansible-awx-postgres   ClusterIP   None           <none>        5432/TCP       8m31s
ansible-awx-service    NodePort    10.97.206.89   <none>        80:32483/TCP   7m55s
devops@linuxtechi:~$

Please make a note of node port of ‘ansible-awx-service’, we will be using it later for port forwarding.

Step 4) Access AWX Portal via tunneling

To access AWX portal outside of minikube cluster, we must configure the tunneling, run

devops@linuxtechi:~$ nohup minikube tunnel &
[3] 35709
devops@linuxtechi:~$
devops@linuxtechi:~$ kubectl get svc ansible-awx-service
NAME                  TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
ansible-awx-service   NodePort   10.97.206.89   <none>        80:32483/TCP   90m
devops@linuxtechi:~$

Set the port forwarding in such a way that, if the request is coming on minikube IP on node port ‘32483’ then it should be redirected to port 80 of awx pod.

devops@linuxtechi:~$ kubectl port-forward svc/ansible-awx-service --address 0.0.0.0 32483:80 &> /dev/null &
[4] 46686
devops@linuxtechi:~$

Now try to access AWX portal from the web browser by using minikube ip address and node port 32483

http://<minikube-ip>:<node-port>

Access-Ansible-AWX-Portal-Minikube

To get the credentials, go back to terminal and run beneath command.

devops@linuxtechi:~$ kubectl get secret ansible-awx-admin-password -o jsonpath="{.data.password}" | base64 --decode
PWrwGWBFCmpd1b47DJffCtK5SqYGzxXF
devops@linuxtechi:~$

Use the username as ‘admin’ and the password as the output of above command, after entering the credentials we will get following dashboard

AWX-Dashboard-minikube

Great, above confirms that Ansible AWX is installed successfully on Kubernetes minikube. That’s all from this article. I hope you have found it informative and in case you have any queries, feel free to write us in below comments section.

Read Also : How to Run and Schedule Ansible Playbook Using AWX GUI

The post How to Install Ansible AWX on Kubernetes Minikube first appeared on LinuxTechi.

Leave a Comment