The following Tutorial will take you through installing AWX the community version of Ansible Tower on Ubuntu 18.04. In this example the Docker Compose version of AWX will be used

There are a few gotchas picked up from installing this that most howto guides miss

Minimum Spec Machine

  • Ubuntu 20.04|18.04 LTS Server (This tutorial focuses on 18.04)
  • At least 4GB of RAM – More is better
  • 2vcpus – More is better
  • 10GB free disk storage - More is better
  • root or user with sudo for ssh

Install Docker

As always update

sudo apt -y update

Install some prerequites for Docker

sudo apt -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common git

Remove any older versions of Docker

sudo apt remove docker docker-engine docker.io containerd runc

Import the GPG Key for Docker

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

We need to add the Docker-CE Repos for Ubuntu

Note on the first line the - at the end
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"
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list

Update

sudo apt update

Install Docker-CE and additional software

sudo apt install docker-ce docker-ce-cli containerd.io

Add your user to the docker user group

sudo usermod -aG docker $USER
newgrp docker

Check Docker Version installed

docker version

Should read something like this

Client: Docker Engine - Community
Version:           19.03.10
API version:       1.40
Go version:        go1.13.10
Git commit:        9424aeaee9
Built:             Thu May 28 22:16:49 2020
OS/Arch:           linux/amd64
Experimental:      false
Server: Docker Engine - Community
Engine:
Version:          19.03.10
API version:      1.40 (minimum version 1.12)
Go version:       go1.13.10
Git commit:       9424aeaee9
Built:            Thu May 28 22:15:20 2020
OS/Arch:          linux/amd64
Experimental:     false
containerd:
Version:          1.2.13
GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version:          1.0.0-rc10
GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version:          0.18.0
GitCommit:        fec3683

Docker is installed

Install Docker Compose

The version of docker compose in the repos is not the latest version to install the latest version we need to run some additional commands

Note: Copy all of this
curl -s https://api.github.com/repos/docker/compose/releases/latest \
| grep browser_download_url \
| grep docker-compose-Linux-x86_64 \
| cut -d '"' -f 4 \
| wget -qi -

Make the file executable

chmod +x docker-compose-Linux-x86_64

Move the file into somewhere in the path

sudo mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

or move the file into /opt and symlink it to a path location

sudo mkdir /opt/docker
sudo mv docker-compose-Linux-x86_64 /opt/docker/docker-compose
sudo ln -s /opt/docker/docker-compose /usr/local/bin/docker-compose

Check the Version Number

docker-compose version

It should look something like this

docker-compose version 1.25.5, build unknown
docker-py version: 4.2.0
CPython version: 3.6.9
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018

We will need to make a note of the version number for later

Docker Compose is installed

GUI For Docker Management (Optional)

I've included instructions for Portainer here as I find it the simplest way of managing my Docker Containers, all of which can be done from the command line. As a busy sysadmin I like quick solutions as i'm learning longer term commands.

On the same machine you've just installed Docker and docker-compose on run the following

docker volume create portainer_data 
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

you can now access Portainer using

http://<ip of machine>:9000

You'll be asked to create an admin user

You will then bas asked which environment your docker is running on, in this case choose Local

This will take you to the main Portainer Dashboard

Navigate around to see Containers or the Networks

Install Prerequisites for AWX

There are some prereqs we need to install

Ansible

Install Ansible from the Ansible PPA

echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main" | sudo tee /etc/apt/sources.list.d/ansible.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367

Install

sudo apt update
sudo apt install -y ansible

Check the installed version

ansible --version

Should read

ansible 2.9.9
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/david/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]

Ansible is installed

Node.JS and NPM

Many tutrials give the wrong command here , on 18.04 when you install node, npm installs automatically

sudo apt install -y nodejs
sudo npm install npm --global

docker-py python module

Install the correct version

sudo apt install python-pip git pwgen vim
sudo pip install requests==2.14.2

Check the version of Docker Compose

docker-compose version

Looking for the line which reads

docker-compose version 1.25.5, build 4667896

Install the docker compose python module

sudo pip install docker-compose==1.25.5

Troubleshooting

Note: Should you get an error when running the playbook / AWX Installrelating to the docker.py or docker compose python module please do the following

sudo apt remove docker-py
sudo apt install -y python3-pip
sudo pip3 install docker-compose==1.25.5

Install AWX

The installation of AWX is done using an Ansible playbook which can be pulled down from the Ansible AWX git repo

Pull down the code from git

sudo su -

pull down the git repo

git clone --depth 50 https://github.com/ansible/awx.git

Navigate to the Install directory

cd awx/installer/

Generate a strong secret

We need to generate a strong secret for the inventory file

pwgen -N 1 -s 30

should generate something random like this

FwAFoVz17XFWAJMKJQqbtC7DeYDYly

Edit the Inventory

The Ansible inventory needs to be updated

vi inventory

Change the following lines

postgres_data_dir=/tmp/pgdocker
docker_compose_dir=/tmp/awxcompose
admin_password=StrongAdminpasswordforWebInterface
secret_key=FwAFoVz17XFWAJMKJQqbtC7DeYDYly

add the following to the end of the file

rabbitmq_password=awxpass
rabbitmq_erlang_cookie=cookiemonster

Run the playbook

Run the following command

ansible-playbook -i inventory install.yml

The install should run through, if it doesn't i've put some troubleshooting tips below

The install takes no longer than 5 minutes

Once complete you can access the Login page

http://serverip/

Troubleshooting

Install Issues

Note: Should you get an error when running the playbook / AWX Installrelating to the docker.py or docker compose python module please do the following

sudo apt remove docker-py
sudo apt install -y python3-pip
sudo pip3 install docker-compose==1.25.5

or change the line in inventory from

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

to

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

Post Install Issues

I and several others have noted that the first time you run the installer you get an AWX Updating screen which will try and refresh but will sit there for hours if you let it

Fix

cd /tmp/awxcompose/
docker-compose stop
cd ~/awx/installer
ansible-playbook -i inventory install.yml

When you head back to http://your awx ip/

You will still see the updating screen

However in less than 5 minutes on my test system I got the login screen

Thoughts

While i'm still learning Ansible from the command line, this AWX install will be core to my home lab and i'll be looking to link it into Rundeck

Install Docker Compose on Ubuntu 20.04/18.04 / CentOS 8 / Debian 10 / Fedora 32/31
Home