Ansible
How To Perform A Basic Install Of AWX On A Single-Node Lightweight Kubernetes Distribution

How To Perform A Basic Install Of AWX On A Single-Node Lightweight Kubernetes Distribution

Following these steps you can be up and running with a basic AWX node to provide a simple user interface for managing all of your Ansible automation projects.

For this guide I am going to be using the awx-operator to provide a more Kubernetes-native installation method for AWX via an AWX Custom Resource Definition (CRD). The basic install steps provided in the official awx-operator guide suggests using minikube for the Kubernetes cluster. As an alternative I will be using k3s, as I also find it a neatly packaged, simple to use, and lightweight distribution. I will also be using Ubuntu 20.04 LTS as the base distribution.

Install k3s

K3s can be installed from a script that can be executed from a simple curl command. Before that I will make sure Ubuntu is up-to-date and any packages that will be needed later are installed.

Update distribution:
sudo apt update && sudo apt dist-upgrade -y
sudo apt install curl git make

Install k3s:
curl -sfL https://get.k3s.io | sh -

Check the node is ready:
kubectl get nodes

Install k3s:
curl -sfL https://get.k3s.io | sh -

Deploy the awx-operator

The next step is to clone the awx-operator git repository and optionally checkout the release we wish to use:
git clone https://github.com/ansible/awx-operator.git
Change to the awx-operator directory:
cd awx-operator
At the time of writing the current release of the awx-operator is version 0.30.0. As well as being shown on the main repository page on Github you can also view what current branch you are using with the command:
git branch
The output will probably show you are in the ‘devel’ branch. I wish to use 0.30.0 so will use git checkout to change it:
git checkout 0.30.0
and then check the output of git branch again.

git checkout

The next steps is to create a namespace awx environment variable:
export NAMESPACE=awx
and then deploy the awx-operator with command:
make deploy
after a minute or two the awx-operator pods should be ready and the status can be checked with command:
kubectl get pods -n awx

Deploy AWX

The next step is to create and configure an awx deployment manifests which will dictate how we want to deploy AWX. I’ve created example templates which can be downloaded from my github using wget.

mkdir awx-deploy
wget https://raw.githubusercontent.com/lpwoodhouse/cheat_sheets/main/installing_awx/awx-deploy/01-secret.yaml

---
apiVersion: v1
kind: Secret
metadata:
  name: awx-postgres-configuration
  namespace: awx
stringData:
  host: awx-postgres
  port: "5432"
  database: awx
  username: awx
  password: <awxdatabaseadmin>    # Set the database password you wish to use.
  type: managed
type: Opaque

---
apiVersion: v1
kind: Secret
metadata:
  name: awx-admin-password
  namespace: awx
stringData:
  password: <awxadmin>    # Set the default Admin password for awx.
type: Opaque

Edit the manifest 01-secret.yaml and replace the password variables with desired values.
Apply the manifest with:
kubectl apply -f 01-secret.yaml

Next download or create the second manifest 02-awx.yaml
wget https://raw.githubusercontent.com/lpwoodhouse/cheat_sheets/main/installing_awx/awx-deploy/02-awx.yaml

---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx
  namespace: awx
spec:

  admin_user: admin
  admin_password_secret: awx-admin-password

  service_type: nodeport
  ingress_type: none
  hostname: awx.example.com     # Replace fqdn.awx.host.com with Host FQDN and DO NOT use IP.
  
  postgres_configuration_secret: awx-postgres-configuration

Edit the manifest 02-awx.yaml and replace the hostname variable with the fqdn of the host.
The next step is to deploy using command:
kubectl apply -f 02-awx.yaml

This deployment can take upwards of 10 minutes to compete and can be monitored using command:
kubectl -n awx logs -f deployments/awx-operator-controller-manager -c awx-manager

Leave a Reply

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