Installing Ansible AWX using Docker

2 minute read


After installing Ansible to test within a Windows environment, I wanted to explore other methods of administering and using Ansible other than from the commandline.


Although there was a commercial product called Ansible Tower available for testing, I wanted to explore the upstream project called AWX instead, as this had no licensing restrictions or limits on how many nodes it could manage.

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible.

My Vagrantfile installs Docker and Ansible AWX during vagrant up, but I’ve included the steps below for reference.

Installing Docker

Before installing Ansible AWX, Docker needs to be installed.

Use the script below to install the Extra Packages Repo and other useful utils if required:

Run the script below to install Docker CE:

Installing Ansible AWX

Run the script below to install Ansible AWX:

Part of the above copies an Inventory file used to configure Docker, Postgres, RabbitMQ, and AWX. My configuration is shown below:

Build Verification

Once the Vagrant build has finished, you can check the progress of the final import / migration tasks within Docker by following the steps below:

  1. From within the cloned repo folder (eg ~\Code\Ansible-Windows), connect to the Ansible Control VM by running:
     vagrant ssh ansible01
  2. List running containers:
     sudo docker ps
  3. Tail the logs for the awx_task container:
     sudo docker logs -f awx_task
  4. Once migrations are complete you will see messages like those shown below (amongst the many DEBUG messages):
# Initial migration log messages
Using /etc/ansible/ansible.cfg as config file | SUCCESS => {
    "changed": false,
    "elapsed": 0,
    "path": null,
    "port": 5432,
    "search_regex": null,
    "state": "started"

... [logs removed for brevity]

Operations to perform:
  Apply all migrations: auth, conf, contenttypes, main, oauth2_provider, sessions, sites, social_django, sso, taggit
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying taggit.0001_initial... OK
  Applying taggit.0002_auto_20150616_2121... OK
  Applying contenttypes.0002_remove_content_type_name... OK

# Final migration log messages
Default organization added
Demo Credential, Inventory, and Job Template added
Successfully registered instance awx
Creating instance group tower

On my dev laptop it took ~20 mins for Ansible Control VM provisioning and build of Docker / Ansible AWX.

Installation Error

During initial testing, my Ansible AWX installation failed with this error:

fatal: [localhost]: FAILED! => {
  "changed": false, 
  "msg": "Failed to import docker or docker-py - No module named 'requests.packages.urllib3'.
  Try pip install docker or pip install docker-py (Python 2.6)"

I had initially included docker-python and docker-compose in the installation scripts, so I removed these lines:

yum -y install docker-python
pip install docker-compose

I then added the Docker SDK for Python via PIP using:

pip install docker

What’s Next?

Check out my next blog post where I go over the steps for testing Ansible AWX with Windows hosts.

Leave a comment