Categories
ansible Containerisation

Installing Ansible AWX (Tower) on Kuberenetes 1.17 (Rancher)

AWX release versions don’t link up that well with ansible towers. The problem with that is that when reading user and admin docs of ansible tower, the versions don’t link up.

Anyway AWX updates versions like wildfire so we are now on AWX version 11, this is probably outdated now so check the latest AWX releases on github.

The documentation goes through the basics of installing AWX.

Prerequisites

You need on your local:

  • git
  • python3.8
  • ansible 2.8+
  • docker python module
  • node 10x and npm 6x (but try without this first)

Resources Specs

Then you will need a kubernetes cluster with the following resources available to workers (not control plane nodes)

  • 4GB memory
  • 2 CPU cores
  • 20GB of space

External DB

I will use the external DB method as it feels a bit safer and I’m not that great with k8s peristent storage volumes and ScaleSet.

So for that you need to install postgres 9.6+ on an accessible vm.

Follow the installation instructions on the postgres website for postgres 9.6+ greater on your server

You will need to create a database and create a remote awx user

sudo su postgres -
createdb awx
psql
create user awx with encrypted password 'awxpass';
grant all privileges on database awx to awx;

Then allow remove access, find where your config files are:

psql -c 'SHOW config_file'
sudo vim /var/lib/pgsql/12/data/postgresql.conf

set

listen_addresses = '*' 

then:

sudo vim /var/lib/pgsql/12/data/pg_hba.conf

set:

host all all 0.0.0.0/0 md5

Restart:

systemctl start postgresql-12

Lastly, allow the port on the firewall

Steps

After setting up the above

  1. Clone the repo locally

    git clone git@github.com:ansible/awx.git

or

    wget https://github.com/ansible/awx/archive/11.0.0.tar.gz
    tar -xf 11.0.0.tar.gz
  1. Edit awx/installer/inventory , provide values for kubernetes_context and kubernetes_namespace

  2. Uncomment and set your external postgres details

    pg_hostname=postgresql
    pg_username=awx
    pg_password=awxpass
    pg_database=awx
    pg_port=5432
  3. Change the admin username and admin password in the inventory

  4. Then run the playbook

    ansible-playbook -i inventory install.yml

Post install you should be able to see the pods

    $ kubectl get pods --namespace awx
    NAME                       READY   STATUS    RESTARTS   AGE
    ansible-tower-management   1/1     Running   0          5m39s
    awx-7586cffcfb-q2lhl       4/4     Running   0          5m59s

View the availble services

kubectl get svc --namespace awx

View the ingress

kubectl get ing --namespace awx

The tricky part is actually accessing the box. I still need to work on this.

So it needs a public ip (or at least an accessible ip) then point your dns (either local in /etc/hosts or proper) to it..

ie. mysite.example.com { rancher_cluster_ip }

Then create a load balancer in rancher or edit the ingress to use the dns name

Sources