Install Ansible AWX on Ubuntu 20.04 using Kubernetes
AWX is the upstream open source version of Ansible Tower, you can install it for free and use it for free forever.
To install on Kubernetes I will be using the AWX-Operator
https://github.com/ansible/awx-operator
For this tutorial I will be installing on an Ubuntu Desktop 20.04 running on ESXi
I am starting from a clean Ubuntu 20.04 installation and will start with updating the packages. Following that the AWX install is very straightforward.
sudo apt update && sudo apt -y upgrade
sudo reboot
I also need to install VMWare tools, net-tools, Git SSH and Virtualenv
If you are new to Git, check out my Git Tutorial for Beginners
sudo apt install open-vm-tools-desktop
sudo apt install net-tools
sudo apt install git
sudo apt install python3-virtualenv
sudo apt install openssh-server
sudo apt install curl
AWX Install Kubernetes
First step is to setup the repos for Kubernetes and Cubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt
/bin/linux/amd64/kubectl
chmod +x ./kubectl
Then we need to make it executable and move it to bin
chmod +x ./kubectl
Then move it to bin so we can run it as any user
sudo mv ./kubectl /usr/local/bin/kubectl
Next we need to install minikube
kubectl version --client
Next install Docker
sudo apt-get update -y && sudo apt-get install -y docker.io
Install minikube
There is an issue installing latest version (currently 1.22) so stable version is 1.21 so use this
curl -Lo minikube https://github.com/kubernetes/minikube/releases/download/v1.21.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
Later versions might have a fix so the below will probably work.
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
Add user to docker group
This is some code
sudo usermod -aG docker $USER
Log in and out – I rebooted server!
Start minikube
minikube start --addons=ingress --cpus=4 --cni=flannel --install-addons=true \ --kubernetes-version=stable --memory=6g --wait=false
Check everything is working with kubectl get pods -A – you should see something like this
roger@AWX:~$ kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
ingress-nginx ingress-nginx-admission-create--1-d7d5p 0/1 Completed 0 13m
ingress-nginx ingress-nginx-admission-patch--1-6bjsb 0/1 Completed 1 13m
ingress-nginx ingress-nginx-controller-69bdbc4d57-mbsvp 1/1 Running 0 13m
kube-system coredns-78fcd69978-5x8jz 1/1 Running 0 13m
kube-system etcd-minikube 1/1 Running 0 13m
kube-system kube-apiserver-minikube 1/1 Running 0 13m
kube-system kube-controller-manager-minikube 1/1 Running 0 13m
kube-system kube-proxy-fkdfn 1/1 Running 0 13m
kube-system kube-scheduler-minikube 1/1 Running 0 13m
kube-system storage-provisioner 1/1 Running 1 (13m ago) 13m
Next install the AWX Operator
kubectl apply -f https://raw.githubusercontent.com/ansible/awx-operator/0.13.0/deploy/awx-operator.yaml
You can check the installation progress by entering this command
kubectl logs -f deployments/awx-operator
If you type kubectl get pod you should see one something like this
roger@AWX:~$ kubectl get pod
NAME READY STATUS RESTARTS AGE
awx-demo-postgres-0 1/1 Running 1 (3m19s ago) 29m
awx-operator-75c79f5489-hvg2t 1/1 Running 1 (3m19s ago) 41m
Next you need to create a file called awx-demo.yml and put the following code into it
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
name: awx-demo
spec:
service_type: nodeport
ingress_type: none
hostname: awx-demo.example.com
Now apply that file
roger@AWX:~$ kubectl apply -f awx-demo.yml
awx.awx.ansible.com/awx-demo created
You now need to wait a few minutes for the creation – you can check status with this command
kubectl get pods -l "app.kubernetes.io/managed-by=awx-operator"
Now you need to get the admin password
kubectl get secrets
kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 --decode
You can now log into your AWX – point your browser to the IP address of your AWX
Do an ifconfig to check your IP – then point to http://<your-ip>
Ansible AWX default credentials
The default credentials for a new Ansible AWX install are.
Ansible AWX is no longer supported on Docker, but if you do need to install it on Docker you have to use V17.01 – details below
Install Ansible AWX 17.0.1 on Ubuntu 20.04 using Docker
AWX is the upstream open source version of Ansible Tower, you can install it for free and use it for free forever.
Latest repo: https://github.com/ansible/awx
However there is no support. If you want a supported version you need to look at Ansible Tower
For this tutorial I am going to be installing AWX 17.0.1 on an Ubuntu Desktop 20.04 running within VMWare workstation
Full install instructions can always be found here – https://github.com/ansible/awx/blob/devel/INSTALL.md
I am starting from a clean Ubuntu 20.04 installation and will start with updating the packages.
sudo apt update && sudo apt -y upgrade
sudo reboot
I also need to install VMWare tools, net-tools, Git SSH and Virtualenv
sudo apt install open-vm-tools-desktop
sudo apt install net-tools
sudo apt install git
sudo apt install python3-virtualenv
Setup Virtual Environment
We now need to setup a virtual environment
I will make a directory called virtual and then create a virtual environment within that directory called awx
mkdir virtual
cd virtual
virtualenv awx
I now need to activate that virtual environment
source awx/bin/activate
Your prompt should now change to this
AWX Install Docker
sudo apt -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker $USER
newgrp docker
Check Docker version
docker version
Install Docker Compose
We now need to install docker-compose, in doing so it will also install Docker, which is also another requirement.
pip3 install docker-compose
We now need to clone the AWX repository from Github, make sure you drop back to your home directory before doing this otherwise you will get an error saying the folder awx already exists
git clone -b 17.0.1 https://github.com/ansible/awx.git
Edit the Inventory file
You now have a folder called awx and within there a folder called installer and within there an inventory file you need to edit.
You just need to make sure you have set an admin password and we need to change the directory of your virtual environment.
Change # admin_password=password to
admin_password=(your secure password)
Find this line
AWX custom virtual environment folder. Only usable for local install.
custom_venv_dir=/opt/my-envs/ and change the path to /home/roger/virtual/awx (make sure you change your local username!)
Install Ansible
To build AWX you need to have Ansible installed to run the install playbook, make sure you are in your virtual environment and run
pip3 install ansible
Run the install Playbook
You need to be in the inventory folder again
ansible-playbook -i inventory install.yml
If everything is in place this should run fully – watch out for any red!
This will take a little while (at least 10 minutes) to run through as it has to pull some images from Docker, but once it completes you should be able to type docker ps and see your running containers
You can now log into your Ansible AWX instance just point your browser to the IP address of your Ansible AWX.
Do an ifconfig to check your IP – then point to http://<your-ip>
You should see this screen
Ansible AWX Login Screen
Application Issues
Docker support has been removed for Ansible AWX so this process might not run for you at a later date if you try to use newer versions.
It is discussed here – https://groups.google.com/g/awx-project/c/47MjWSUQaOc/m/bCjSDn0eBQAJ
Using Ansible for Network Automation is a great to get started with programmability.
AWX will allow you to schedule jobs, and provide an audit path of previously run tasks.
Remember that there is no support with AWX and if you get stuck there is always the Ansible community. If you are looking for a more enterprise friendly tool Ansible Tower might be a better fit, you you do have to pay for a subscription which gets you support.
A lot of companies use AWX with great success, so why not install it and give it a go.
Javier Moncada
Roger, after failing on other guided installation processes, I could make it to get AWX installed following your instructions. Many thanks for the time you took to help to others.
Roger Perkin
That’s great Javier, what you read there is the end to a very frustrating afternoon where once I finally cracked it I wanted to document it! The main issue is that the AWX install is moving away from Docker – so expect an update soon!
Gabor
Tried to install the first version Ubunut+K8S but not much happening after completed all the steps. After the last step “get the secret” what shall I do?? How I access AWX? it seems like the article have not finished. Appreciated though..
Roger Perkin
Just point your browser to the IP of your host
Ken Murphy
Couldn’t get this to work, nothing seems to be listening on port 80?
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:36393 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN –
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.1:49153 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.1:49154 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.1:49155 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.1:49156 0.0.0.0:* LISTEN –
tcp 0 0 127.0.0.1:49157 0.0.0.0:* LISTEN –
tcp6 0 0 :::22 :::* LISTEN –
tcp6 0 0 ::1:631 :::* LISTEN –
udp 0 0 0.0.0.0:60594 0.0.0.0:* –
udp 0 0 127.0.0.53:53 0.0.0.0:* –
udp 0 0 0.0.0.0:631 0.0.0.0:* –
udp 0 0 0.0.0.0:5353 0.0.0.0:* –
udp6 0 0 :::41918 :::* –
udp6 0 0 :::5353 :::* –
raw6 0 0 :::58 :::* 7 –
Roger Perkin
Have you tried https://
carlos montero
Hi Roger,
After many attempts following various guides, I was successful installing AWX using your guide. Thanks a lot.
Only thing I have to change was “host_port=8084”, it was originally 80, but when I run the playbook it was complaining saying that host was already in used.
Thanks again for this guide.
Roger Perkin
Thanks Carlos, glad it helped and good tip on the host_port
Danny
Hi Roger, I think both methods are now deprecated.
I have tried both Docker and Kubernetes ways on Ubuntubu 20.4 neither worked.
Thank you for the article though.
Roger Perkin
It changes all the time! Let me review and update