Running AWX on Minishift

Running AWX on Minishift

The upstream version of Red Hat's Ansible Tower product, is AWX. This is a containerised solution, which means you need a container orchestrator in order to run and look after it. A neat local install option is Minishift, which runs OKD, Red Hat's version of minikube.

If you're already using minishift...

I suggest first blowing away old minishift instances to ensure things go smoothly!

$ minishift stop && minishift delete

$ rm -rf ~/.minishift ~/.kube

Also delete any old minishift-addons you may have laying around

Download and install minishift

Download the latest minishift from https://github.com/minishift/minishift/releases

At the time of writing, I’m using v1.23 for Mac OSX here in combo with Virtualbox

$ tar zxfv the download and put the minishift-* binary somewhere on your PATH - I used /usr/local/bin/minishift

(biggest issues I’ve had with minishift is around upgrades where a conflicting older minishift or oc binary can work but not :(

AWX needs at least 4 cores/8Gb else it won’t install so setup some limits (give it more if you have it or like)

$ minishift config set vm-driver virtualbox

$ minishift config set cpus 4

$ minishift config set memory 8gb

$ minishift config view

$ minishift start

Wait for it to download/install - can take a while if your broadband is like mine :(

Nearly ready to install AWX!

Couple of things to setup before attempting to install AWX…

Make sure we pick up the right oc binary else things can get weird and interesting!

$ eval $(minishift docker-env)

Our normal user (in this case developer) needs extra rights to do things at the cluster level.

oc login -u admin -p admin --as=system:admin

oc adm policy add-cluster-role-to-user cluster-admin admin --as=system:admin

oc adm policy add-cluster-role-to-user cluster-admin developer --as=system:admin
 
  

The AWX playbook install creates a project but it won’t hurt creating it ahead of time so we can create a persistent storage volume for the DB.

$ oc new-project awx

Create a file called pvc.yml with this content:

$ cat > pvc.yml <<EOF

apiVersion: "v1"

kind: "PersistentVolumeClaim"

metadata:

 name: "postgresql"

spec:

 accessModes:

  - "ReadWriteMany"

 resources:

  requests:

   storage: "20Gi"

 volumeName: pv0001

EOF

Minishift creates a number of PVs as part of the install so we can just make a claim for one of these.

$ oc get pv

to view them and pick a free one - replace pv0001 above if its already taken for instance)

$ oc create -f pvc.yml

will make a claim on the PV and get picked up by the installer and used as a persistent volume for the postgres DB.

$ oc get pvc 

to see the claim - needs to show ‘Bound'

AWX Installation

Finally there!

$ git clone https://github.com/ansible/awx.git

$ cd awx/installer

You need to make some changes to the inventory file before things will suit your environment

$ cp inventory inventory.old

This works for my inventory file:

$ cat > inventory <<EOF

localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python"



[all:vars]



dockerhub_base=ansible

dockerhub_version=latest



openshift_host=192.168.99.100:8443

openshift_project=awx

openshift_user=developer

openshift_skip_tls_verify=True

openshift_pg_emptydir=False



postgres_data_dir=/tmp/pgdocker

host_port=80

docker_compose_dir=/var/lib/awx



pg_username=awx

pg_password=awxpass

pg_database=awx

pg_port=5432



default_admin_user=admin

default_admin_password=password

secret_key=awxsecret

EOF
 
  

The only thing which you should need to possibly change is the openshift_host IP. You can check yours by running

$ minishift ip

Now we’re good to go!

$ ansible-playbook -i inventory install.yml -e openshift_password=developer -e docker_registry_password=$(oc whoami -t)

The playbook will fire off all sorts of tasks, some might fail (and show up in red). This is fine normally.

Login to the minishift console using

$ minishift console

and credentials developer/developer to see what’s happening under the covers!

Select the awx project from the GUI and you’ll start to see pods/containers being created

NB. The ansible-tower-management pod will come and go once the postgres DB has been setup. TASK [kubernetes: Migrate database] does this from the playbook run.

After a few mins you should end up with a summary such as:

< PLAY RECAP >

 ------------

    \ ^__^

     \ (oo)\_______

      (__)\   )\/\

        ||----w |

        ||  ||



localhost         : ok=35 changed=17 unreachable=0  failed=0

As long as unreachable and failed=0 you should be good to go!

Click on the route under the awx resource in the GUI and the AWX GUI should allow you to login using admin/password (from the inventory file above)

Make sure the pod circle is blue and therefore ‘ready’


Gotchas:

minishift and/or oc binaries not in sync with release being used. Can seem to work, to a degree! When in doubt. blow away old config!

PVC claim seemed to capture the quotes around pv0001 and wouldn’t bind, so I removed them and it worked. Maybe just a copy and paste error!


Sander Plug

Director Enterprise Architecture

3y

Nice instruction. I followed it on Windows 10 (minishift + virtualbox) and WLS Ubuntu 18.04 for ansible / oc commands. Most seem to work fine. Postgres pod starts, but the ansible management pod does not. I get a Create Container Config Error and the following error message: "Error: failed to create subPath directory for volumeMount "awx-secret-key" of container "ansible-tower-management"". Have you seen that as well? Any idea how to fix that?

Like
Reply

To view or add a comment, sign in