For those who seeks help in different areas of Software and Hardware platform

How To Install Ansible AWX on CentOS/RHEL 7/8

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. This tutorial will walk you through the steps to set up Ansible AWX using Docker on a CentOS/RHEL 7/8.


To follow this tutorial along, you will need one (physical or virtual) machine with CentOS/RHEL 7/8 minimal installed, must have root user privileges.

Configure SELinux

By default, SELinux is enforcing in CentOS/RHEL 7/8. It is recommended to change SELINUX=enforcing to SELINUX=disabled to run Ansible AWX error free:
nano /etc/sysconfig/selinux
Replace the value "enforcing" with "disabled":
Save and close the file.

Reboot your machine to apply changes, when reboot complete, proceed with the below.

Install EPEL Repository

You will need to install the extra packages for enterprise Linux (EPEL) repository on your CentOS/RHEL 7/8:

Type below command if you are running CentOS/RHEL 8:
dnf -y install epel-release
Type below command if you are running CentOS/RHEL 7:
yum -y install epel-release

Install Required Packages

Type below to install these additional packages if you are running a CentOS/RHEL 8:
dnf -y install git gcc gcc-c++ ansible nodejs gettext device-mapper-persistent-data lvm2 bzip2 python3-pip python-docker nano
Type below if you are running a CentOS/RHEL 7:
yum -y install git gcc gcc-c++ ansible nodejs gettext device-mapper-persistent-data lvm2 bzip2 python3-pip python-docker nano

Install Docker

Type below to add Docker official repository on CentOS/RHEL 8:
dnf config-manager --add-repo=
Type below to add Docker official repository on CentOS/RHEL 7:
yum-config-manager --add-repo
Type below command to install Docker on CentOS/RHEL 8:
dnf -y install docker-ce
Type below command to install Docker on CentOS/RHEL 7:
yum -y install docker-ce
Next, start the Docker service and make it persistent even when system reboot with below command:
systemctl start docker
systemctl enable docker
Confirm that docker is active and running:
systemctl status docker
You will see similar output like below:

Type below to install Docker Compose on CentOS/RHEL 7/8:
pip3 install docker-compose
You will see the output like below:
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting docker-compose
  Downloading (136kB)
    100% |████████████████████████████████| 143kB 38kB/s
Collecting PyYAML<6>=3.10 (from docker-compose)
  Downloading (269kB)
    100% |████████████████████████████████| 276kB 14kB/s
Collecting requests<3>=2.20.0 (from docker-compose)
  Downloading (58kB)
    100% |████████████████████████████████| 61kB 8.2kB/s
Collecting six<2>=1.3.0 (from docker-compose)
Collecting websocket-client<1>=0.32.0 (from docker-compose)
  Downloading (200kB)
    100% |████████████████████████████████| 204kB 27kB/s
Collecting dockerpty<1>=0.4.1 (from docker-compose)
Collecting docker[ssh]<5>=3.7.0 (from docker-compose)
  Downloading (143kB)
    100% |████████████████████████████████| 153kB 15kB/s
Collecting jsonschema<4>=2.5.1 (from docker-compose)
  Downloading (56kB)
    100% |████████████████████████████████| 61kB 32kB/s
Collecting cached-property<2>=1.2.0 (from docker-compose)
Collecting texttable<2>=0.9.0 (from docker-compose)
Collecting docopt<1>=0.6.1 (from docker-compose)
Collecting idna<3>=2.5 (from requests<3>=2.20.0->docker-compose)
  Downloading (58kB)
    100% |████████████████████████████████| 61kB 13kB/s
Collecting chardet<4>=3.0.2 (from requests<3>=2.20.0->docker-compose)
  Downloading (133kB)
    100% |████████████████████████████████| 143kB 17kB/s
Collecting certifi>=2017.4.17 (from requests<3>=2.20.0->docker-compose)
  Downloading (156kB)
    100% |████████████████████████████████| 163kB 5.9kB/s
Collecting urllib3!=1.25.0,!=1.25.1,<1 .26="">=1.21.1 (from requests<3>=2.20.0->docker-compose)
  Downloading (125kB)
    100% |████████████████████████████████| 133kB 66kB/s
Collecting paramiko>=2.4.2; extra == "ssh" (from docker[ssh]<5>=3.7.0->docker-compose)
  Downloading (206kB)
    100% |████████████████████████████████| 215kB 134kB/s
Collecting pyrsistent>=0.14.0 (from jsonschema<4>=2.5.1->docker-compose)
  Downloading (108kB)
    100% |████████████████████████████████| 112kB 137kB/s
Collecting attrs>=17.4.0 (from jsonschema<4>=2.5.1->docker-compose)
Collecting importlib-metadata; python_version < "3.8" (from jsonschema<4>=2.5.1->docker-compose)
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from jsonschema<4>=2.5.1->docker-compose)
Collecting pynacl>=1.0.1 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading (759kB)
    100% |████████████████████████████████| 768kB 126kB/s
Collecting bcrypt>=3.1.3 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading (56kB)
    100% |████████████████████████████████| 61kB 244kB/s
Collecting cryptography>=2.5 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading (2.3MB)
    100% |████████████████████████████████| 2.3MB 57kB/s
Collecting zipp>=0.5 (from importlib-metadata; python_version < "3.8"->jsonschema<4>=2.5.1->docker-compose)
Collecting cffi>=1.4.1 (from pynacl>=1.0.1->paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading (399kB)
    100% |████████████████████████████████| 399kB 41kB/s
Collecting pycparser (from cffi>=1.4.1->pynacl>=1.0.1->paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5>=3.7.0->docker-compose)
  Downloading (112kB)
    100% |████████████████████████████████| 112kB 35kB/s
Installing collected packages: PyYAML, idna, chardet, certifi, urllib3, requests, six, websocket-client, dockerpty, pycparser, cffi, pynacl, bcrypt, cryptography, paramiko, docker, pyrsistent, attrs, zipp, importlib-metadata, jsonschema, cached-property, texttable, docopt, docker-compose
  Running install for PyYAML ... done
  Running install for dockerpty ... done
  Running install for pyrsistent ... done
  Running install for docopt ... done
Successfully installed PyYAML-5.3.1 attrs-19.3.0 bcrypt-3.1.7 cached-property-1.5.1 certifi-2019.11.28 cffi-1.14.0 chardet-3.0.4 cryptography-2.8 docker-4.2.0 docker-compose-1.25.4 dockerpty-0.4.1 docopt-0.6.2 idna-2.9 importlib-metadata-1.5.2 jsonschema-3.2.0 paramiko-2.7.1 pycparser-2.20 pynacl-1.3.0 pyrsistent-0.16.0 requests-2.23.0 six-1.14.0 texttable-1.6.2 urllib3-1.25.8 websocket-client-0.57.0 zipp-3.1.0
Once you are finished with docker compose installation, type the below command to set python 3 in the environment variable:
alternatives --set python /usr/bin/python3
Type below command to verify whether python version 3 is default:
python --version
You should see output like below:
Python 3.6.8

Download Ansible AWX

You can download Ansible AWX latest release from the Git Hub repository using the below command:
cd ~
git clone

When download complete, type below command to generate a secret key using openssl and that key will be used to encrypt inventory file:
openssl rand -base64 30
You will see the output similar to the following:

Copy your key and save it for later use in the inventory file.

Install Ansible AWX

You need to edit inventory file like below:
cd ~/awx/installer/
nano inventory
Find the following directives, uncomment them by removing #, replace these highlighted values with yours:
Save and close the file when you are finished.

Next, create a pgdocker directory under /var/lib/
mkdir /var/lib/pgdocker
Type the following command to install AWX:
cd ~/awx/installer
ansible-playbook -i inventory install.yml
This will create and start all the required Docker containers for Ansible AWX.

You can verify the running containers with the following command:
docker ps

Add Firewall Rules

You will need to add following rules to allow http and https service to pass through firewalld:
firewall-cmd --zone=public --add-masquerade --permanent
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

Access AWX Web Interface

Open up your preferred web browser and type the http://your-server-ip in the address bar, you will be redirected to the login page like below:

Log in with the admin username and password which you have defined in the inventory file, you should see the default dashboard like below:

Wrapping up

Now that you have Ansible AWX running, you can now administer and manage your Ansible project easily using the AWX web interface.


Post a Comment

Comments with links will not be published.