Skip to content
Indus LeveL
ansible awx docker centos automation devops

How to Install Ansible AWX with Docker on CentOS 7

A comprehensive, step-by-step guide to installing Ansible AWX using Docker on CentOS 7, including configuration and client node setup.

2 min read
Cover image for Ansible AWX installation guide

Ansible is an incredibly powerful automation tool, but managing playbooks, inventories, and credentials across a team via the CLI can become cumbersome. This is where Ansible AWX—the open-source upstream project for Red Hat Ansible Tower—comes in. AWX provides a web-based user interface, REST API, and task engine built on top of Ansible.

In this guide, I will walk you through the complete process of installing Ansible AWX using Docker on CentOS 7, resolving common dependency conflicts, configuring the installer inventory, and setting up client nodes for passwordless automation.

Prerequisites

Before starting, ensure you have a clean CentOS 7 VM or server with root access. We will be installing Docker CE, Ansible, and Docker Compose as part of the setup.


Step 1: System Update and SELinux Configuration

First, update the system packages and install required utilities. For AWX to function smoothly with Docker on CentOS 7, it is recommended to disable SELinux.

yum update -y
yum install epel-release.noarch yum-utils.noarch -y
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

Reboot the server to apply the SELinux changes:

reboot

Step 2: Firewall and Docker CE Installation

Once back online, open the HTTP service in the firewall so the AWX web interface will be accessible.

firewall-cmd --permanent --add-service=http
firewall-cmd --reload
firewall-cmd --list-all

Next, add the official Docker CE repository and install Docker, Ansible, Git, and helpful monitoring utilities like htop, iftop, and atop.

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce ansible git bash-completion iftop htop atop -y

Start and enable the Docker service:

systemctl start docker
systemctl enable docker
systemctl status docker
source /etc/profile.d/bash_completion.sh

Step 3: Resolving Python and Docker-Py Dependencies

A common stumbling block when installing AWX on CentOS 7 is dependency conflicts between docker-py and docker Python packages. To ensure a clean environment, we will install pip and upgrade docker-compose while specifically avoiding the conflicting packages.

yum install python2-pip -y 
pip install --upgrade pip
pip uninstall cryptography -y
pip install cryptography -y
pip install docker-compose

Step 4: Download AWX Source Code and Logos

Clone the official AWX repository and the AWX logos repository into /root.

cd /root/
git clone https://github.com/ansible/awx.git
cd /root/awx/
git clone https://github.com/ansible/awx-logos.git

Step 5: Configure Installer Inventory

AWX is installed by running an Ansible playbook that deploys Docker containers. We need to modify the default inventory file to customize data directories, enable official logos, and specify DNS servers.

Run the following sed commands to update the inventory configuration:

# Change PostgreSQL data directory to /var/lib/pgdocker
sed -i 's+postgres_data_dir=/tmp/pgdocker+postgres_data_dir=/var/lib/pgdocker+g' /root/awx/installer/inventory

# Enable official AWX logos
sed -i '/awx_official=false/s/^#//g' /root/awx/installer/inventory
sed -i 's/awx_official=false/awx_official=true/g' /root/awx/installer/inventory 
sed -i 's+ awx_official=true+awx_official=true+g' /root/awx/installer/inventory

# Set alternate DNS servers to Google Public DNS
sed -i '/awx_alternate_dns_servers=/s/^#//g' /root/awx/installer/inventory
sed -i 's+awx_alternate_dns_servers="10.1.2.3,10.2.3.4"+awx_alternate_dns_servers="8.8.8.8,8.8.4.4"+g' /root/awx/installer/inventory

# Enable project data directory
sed -i '/project_data_dir=/s/^#//g' /root/awx/installer/inventory

# Set Docker Compose directory to /var/lib/awx
sed -i 's+docker_compose_dir=/tmp/awxcompose+docker_compose_dir=/var/lib/awx+g' /root/awx/installer/inventory

To verify your changes, check the active configuration lines in the inventory file:

cat /root/awx/installer/inventory | egrep -v "#|^$"

Step 6: Run the Installation Playbook

Navigate to the installer directory and execute the install.yml playbook. This process pulls all required Docker images and spins up the AWX containers (Web UI, Task engine, PostgreSQL, Memcached, and RabbitMQ).

cd /root/awx/installer/
ansible-playbook -i inventory install.yml -vvvvvv

Step 7: Setting Up Client Nodes for Automation

To actually manage target servers (clients) using AWX, we need to configure a dedicated ansible user on both the AWX server and the client machines with passwordless sudo access and SSH key authentication.

On Client Servers

Execute the following on each target machine you wish to manage:

useradd ansible
echo "Temp/123" | passwd --stdin ansible
echo "ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ansible

On the AWX Server

Similarly, create the user on the AWX server and generate an SSH key pair:

useradd ansible
echo "Temp/123" | passwd --stdin ansible
echo "ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ansible

su - ansible
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -f ~/.ssh/id_rsa -t rsa -N ''

Copy the public key to your client machines (replace omh-ansible-client1.induslevel.com with your actual client hostnames or IP addresses):

ssh-copy-id -i ~/.ssh/id_rsa.pub omh-ansible-client1.induslevel.com
ssh omh-ansible-client1.induslevel.com
exit

ssh-copy-id -i ~/.ssh/id_rsa.pub omh-ansible-client2.induslevel.com
ssh omh-ansible-client2.induslevel.com
exit

Step 8: Hardening Security (Removing Temporary Passwords)

Once SSH keys are successfully deployed, remove the temporary passwords from the ansible user on all machines to enforce key-only authentication.

On the AWX Server

su -
passwd -d ansible

On Client Machines (via SSH from AWX server)

su - ansible
ssh omh-ansible-client1.induslevel.com
sudo passwd -d ansible
exit

ssh omh-ansible-client2.induslevel.com
sudo passwd -d ansible
exit

Your Ansible AWX platform is now fully deployed and securely configured to manage your infrastructure!

References

Back to Blog
Share:

Follow along

Stay in the loop — new articles, thoughts, and updates.