How to Install Ansible with AWX on Ubuntu 18.04 | 16.04

graphic designer 4562741 640

This brief tutorial shows students and new users how to install Ansible with AWX on Ubuntu 18.04 | 16.04.

Ansible is an open source software provisioning, configuration management, and application-deployment tool that allows configuration managers painless process to manage and deploy applications and services across diverse environments.

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. With both work together to provide web based portal to manage and automate Ansible.

AWX allows you to easily and centrally manage Ansible playbooks, inventories, Secrets, and scheduled jobs from a web interface.

To get started with installing Ansible AWX on Ubuntu, follow the steps below:

Step 1: Install Docker and Docker Compose

Docker has two editions:  The Enterprise Edition (EE) and the Community Edition (CE).

For this tutorial, we’re going to be installing the community edition of Docker.

If you always want to automatically get the latest version of Docker on Ubuntu, you must add its official repository to Ubuntu system. To do that, run the commands below to install prerequisite packages.

sudo apt update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Next, run the commands below to download and install Docker’s official GPG key. The key is used to validate packages installed from Docker’s repository making sure they’re trusted.

curl -fsSL | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88

You should see an output shown below:

pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <>
sub   rsa4096 2017-02-22 [S]

Now that the official GPG key is installed, run the commands below to add its stable repository to Ubuntu. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below.

sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

At this point, Docker’s official GPG and repository should be installed on Ubuntu.

For those who currently have older versions of Docker, run the commands below to remove them.

sudo apt-get remove docker docker-engine containerd runc

When you have remove all previous versions of Docker, run the commands below to install the latest and current stable version of Docker.

To install specific version of Docker, run the apt-cache command.Then select the version to install.

apt-cache madison docker-ce

docker-ce | 5:18.09.5~3-0~ubuntu-bionic | bionic/stable amd64 Packages
docker-ce | 5:18.09.4~3-0~ubuntu-bionic | bionic/stable amd64 Packages
docker-ce | 5:18.09.3~3-0~ubuntu-bionic | bionic/stable amd64 Packages
docker-ce | 5:18.09.2~3-0~ubuntu-bionic | bionic/stable amd64 Packages

Now to install a specific version, run the commands below with the version you wish to install

sudo apt-get install docker-ce=5:18.09.5~3-0~ubuntu-bionic docker-ce-cli=5:18.09.5~3-0~ubuntu-bionic

If you just want to latest version without specifying above, run the commands below. The command below will always install the highest possible version.

sudo apt update
sudo apt-get install docker-ce docker-ce-cli

That should install Docker software on Ubuntu.

Add your account to Docker group and restart.

sudo usermod -aG docker $USER
sudo systemctl restart docker

Verify that Docker CE is installed correctly by running the hello-world image, run the commands below:

sudo docker run hello-world

You should see a similar lines as below:

Hello from Docker!
This message shows that your installation appears to be working correctly.

Docker is installed correctly!

Install Docker Compose

On Ubuntu Linux, you can download the Docker Compose binary from the Compose repository release page on GitHub.

To install it, run the commands below to download version 1.24.0. As of this writing this was the current version.

sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

To install a different version of Compose, substitute 1.24.0 with the version of Compose you want to use.

After downloading it, run the commands below to apply executable permissions to the binary file and create a symbolic link to /usr/binary

sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

That should get Docker Compose working. To test, run the commands below:

docker-compose --version

You should see similar output as below:

docker-compose version 1.24.0, build 0aa59064

This is how to install Docker and Docker Compose on Ubuntu

Step 2: Install Ansible

Now that Docker and Docker Compose are installed, use the commands below to install the latest version of Ansible.

echo "deb bionic main" | sudo tee /etc/apt/sources.list.d/ansible.list
sudo apt-key adv --keyserver --recv-keys 93C4A3FD7BB9C367
sudo apt update
sudo apt install ansible

After installing, you can use the commands below to verify that Ansible is installed and show its version number.

ansible --version

The commands should output similar lines as shown below

ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/richard/.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, Nov  7 2019, 10:07:09) [GCC 7.4.0]

Step 3: Install AWX

At this point, Docker, Docker Compose and Ansible should be installed.

Next, follow the steps below to install AWX. First install and configure few prerequisite packages.

sudo apt install nodejs npm
sudo npm install npm --global
sudo apt install python-pip git pwgen
pip install docker

Next, clone AWX source code from GitHub using the git command.

cd ~/
git clone --depth 50

Change into the installer folder

cd ~/awx/installer/

Generate AWX secret key using the commands below. You’ll need this key in the configuration file below:

pwgen -N 1 -s 30

It should output a strong similar to the one below. Copy and save it somewhere.


After that, open the inventory file and add the secret key generated above and save the file.

nano inventory

Edit the highlighted line and save the file

# This will create or update a default admin (superuser) account in AWX, if not provided
# then these default values are used

# Whether or not to create preload data for demonstration purposes

# AWX Secret key
# It's *very* important that this stay the same between upgrades or you will lose the ability to decrypt
# your credentials

# Build AWX with official logos

Next, run ansible-playbook command below to install and configure its environment.

The name of the playbook file is install.yml.

ansible-playbook -i inventory install.yml

After a brief moment, the setup should complete.

When done, open your browser and browse to the server hostname or IP address.


That should bring up AWX portal to login.

Ansible AWX Ubuntu

Login with the username password in the configuration file above.

Default is admin and password

Ansible AWX Ubuntu



This post showed you how to install and configure Ansible AWX on Ubuntu 18.04 | 16.04. If you find any error above, please use the comment form below to report.


You may also like the post below:


  1. Great post, but had issues with two things. 1. Have to log out after adding user to docker group. 2. PIP3 rather than PIP to install docker and docker-compose python modules.

  2. I got a problem when running the playbook, the task local_docker start the container is failed. How I solve it?

  3. Hi!
    I got an issue, mentioned the error below. can you solve it asap?
    fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on ip-172-31-16-68’s Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named ‘docker'”}

    1. Got same error too

    2. make sure that you run the pip install docker command with non root user, then make sure that you run the playbook with a regular user ( not the root).
      If you get a problem of “permission denied ” make sure that this command sudo usermod -aG docker $USER has successfully added docker group to your user

  4. There isn’t installer directory under awx

    1. Hi Saurabh. I think it has recently been taken off. Starting from version 18.0 they are changing the way AWX is installed. You can download an older version of AWX from Github, guess up until 16.0 it has the installer directory.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.