Install Ansible AWX on CentOS 7

by Daniel Pham
Published: Updated:
This entry is part 1 of 1 in the series Ansible AWX Tutorials

This article will guide you how to install Ansible AWX on CentOS 7. Ansible AWX is an open source software located on top of Ansible, which allows system administrators to manage their IT infrastructure easier.

The installation steps in this article have been successfully tested on a 64 bit CentOS Linux release 7.5.1804 (Core) server.

Hardware requirements

The system that runs the Ansible AWX service will need to satisfy the following requirements:

  • RAM: at leasts 4GB of memory.
  • CPU: at least 2 cpu cores.
  • HDD: at least 20GB of space.
  • Running Docker, Openshift, or Kubernetes.
  • If you choose to use an external PostgreSQL database, please note that the minimum version is 9.4.

Install the dependency package

Step 1: Disable SElinux and reboot the server.

You run the following command to replace enforcing with disabled in the config file of SElinux.

sed -i 's|SELINUX=enforcing|SELINUX=disabled|g' /etc/selinux/config

And then reboot the server:

reboot

Step 2: Install the dependency packages required for AWX.

You run the following commands in turn:

yum -y install epel-release
yum -y install git gcc gcc-c++ lvm2 bzip2 gettext nodejs yum-utils device-mapper-persistent-data ansible python-pip

Step 3: Install Docker-CE.

First, you run the command below to remove the old version of Docker on the server (if any).

yum -y remove docker docker-common docker-selinux docker-engine

Next, you add the Docker-CE repository to the server.

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

And now you run the command below to install Docker-CE.

yum -y install docker-ce

After installing Docker-CE, you enable and start the docker service.

systemctl start docker && systemctl enable docker

AWX require docker python module and you can install it via pip.

pip install -U docker-py

Then run the following command to check the installed version.

pip show docker-py

The results displayed on the screen will be similar to the following.

---
Metadata-Version: 2.0
Name: docker-py
Version: 1.10.6
Summary: Python client for Docker.
Home-page: https://github.com/docker/docker-py/
Author: Joffrey F
Author-email: [email protected]
Installer: pip
License: UNKNOWN
Location: /usr/lib/python2.7/site-packages
Requires: websocket-client, requests, backports.ssl-match-hostname, ipaddress, six, docker-pycreds
Classifiers:
Development Status :: 4 - Beta
Environment :: Other Environment
Intended Audience :: Developers
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Topic :: Utilities
License :: OSI Approved :: Apache Software License

Install Ansible AWX on CentOS 7

Step 1: Clone AWX from the repository.

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

The result of the clone implementation will be similar to the following.

Cloning into 'awx'...
remote: Enumerating objects: 9383, done.
remote: Counting objects: 100% (9383/9383), done.
remote: Compressing objects: 100% (5148/5148), done.
remote: Total 9383 (delta 5773), reused 6229 (delta 4103), pack-reused 0
Receiving objects: 100% (9383/9383), 16.43 MiB | 7.59 MiB/s, done.
Resolving deltas: 100% (5773/5773), done.

Step 2: Edit file inventory before installation.

Move to folder awx/installer

cd awx/installer/

Now run the command below to see what parameters are active in the inventory file.

grep -v '^ *#' inventory | sed '/^$/d'

Here are the parameters in the default file.

localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python"
[all:vars]
dockerhub_base=ansible
awx_task_hostname=awx
awx_web_hostname=awxweb
postgres_data_dir=/tmp/pgdocker
host_port=80
docker_compose_dir=/var/lib/awx
pg_username=awx
pg_password=awxpass
pg_database=awx
pg_port=5432
rabbitmq_password=awxpass
rabbitmq_erlang_cookie=cookiemonster
admin_user=admin
admin_password=password
create_preload_data=True
secret_key=awxsecret

If you install AWX on the localhost (machine you are doing the command on it) then you do not care about the other parameters.

You just edit the two main parameters that are:

Parameter 1: admin_password.

You run the command below to edit the parameter admin_password and you change yournewpass using your password.

sed -i 's|admin_password=password|admin_password=yournewpass|g' inventory

Parameter 2: secret_key.

Next, run the following command to automatically generate a new random string, which will be used for secret_key.

openssl rand -base64 30
EuO3d2h8NXdb5rvfGPj0FVaZRsMV2p8dnDwY6w2Q

Then you run the command below to replace the secret_key in the inventory file with the random sequence created above.

sed -i 's|secret_key=awxsecret|secret_key=EuO3d2h8NXdb5rvfGPj0FVaZRsMV2p8dnDwY6w2Q|g' inventory

Now that you run the command that displays the active parameters in the inventory file again, check that the value has been replaced exactly as you did. This is just to be sure, no obligation.

grep -v '^ *#' inventory | sed '/^$/d'

The results:

localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python"
[all:vars]
dockerhub_base=ansible
awx_task_hostname=awx
awx_web_hostname=awxweb
postgres_data_dir=/tmp/pgdocker
host_port=80
docker_compose_dir=/var/lib/awx
pg_username=awx
pg_password=awxpass
pg_database=awx
pg_port=5432
rabbitmq_password=awxpass
rabbitmq_erlang_cookie=cookiemonster
admin_user=admin
admin_password=yournewpass
create_preload_data=True
secret_key=EuO3d2h8NXdb5rvfGPj0FVaZRsMV2p8dnDwY6w2Q

Step 3: Install Ansible AWX.

After you have finished editing the inventory file, run the following command to proceed with the AWX installation.

ansible-playbook -i inventory install.yml

The process of creating containers and settings will take about 15-20 minutes, depending on your system.

Install Ansible AWX
Install Ansible AWX.

After the installation is complete, run the following command to display the created containers. If everything is OK then 5 containers are created correspondingly as below.

docker ps

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                 NAMES
748d34f72bd3        ansible/awx_task:2.1.0       "/tini -- /bin/sh -c…"   2 minutes ago       Up 2 minutes        8052/tcp                                              awx_task
a2c77e4551cc        ansible/awx_web:2.1.0        "/tini -- /bin/sh -c…"   3 minutes ago       Up 3 minutes        0.0.0.0:80->8052/tcp                                  awx_web
529da29c4be5        memcached:alpine             "docker-entrypoint.s…"   9 minutes ago       Up 9 minutes        11211/tcp                                             memcached
7c615c5b43b2        ansible/awx_rabbitmq:3.7.4   "docker-entrypoint.s…"   9 minutes ago       Up 9 minutes        4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   rabbitmq
1aa8573a0416        postgres:9.6                 "docker-entrypoint.s…"   11 minutes ago      Up 11 minutes       5432/tcp                                              postgres

Now open your browser and access the AWX interface with your server’s IP. Ex: http://192.168.10.10

Access Ansible AWX login page
Access Ansible AWX login page.

Inside dashboard look like this.

Inside Ansible AWX dashboard
Inside Ansible AWX dashboard.

Setup HTTPS

To set up https for the AWX login page, you can use a reverse nginx proxy with an SSL certificate on it.

This nginx server can be installed separately from AWX server or install with AWX.

Since the article has been quite long and the purpose is to successfully install Ansible AWX first, the reverse proxy settings I will write in the next section.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating

You may also like

Subscribe
Notify of
guest
31 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
sudheer
sudheer
Guest
4 years ago

Hi mate,

Thanks for making life easier. you may need to update few things. this is totally my suggestion based upon recent experience.
I am installing AWX on Centos7.7
1. include the step to configure python interpreter version based upon requirement i.e. 2.7 or 3.6
2. update the inventory file accordingly with correct python interpreter.
3. recently docker-compose is required which installs docker and other . so, if we install as per the step it gives error “Cannot have both the docker-py and docker python modules installed together as they use the same namespace and cause a corrupt installation” error installing AWX
Even though my example involves AWX,.
Solution:
pip uninstall docker docker-py docker-compose && pip install docker-compose

rednthor
rednthor
Guest
4 years ago

hi can you help me i have this error
It says destination directory /home/bounty/.awx/awxcompose does not exist

Dalibor Hinic
Dalibor Hinic
Guest
4 years ago

Hi guys,

This is the error i get when i try to install awx..any ideas?
TASK [local_docker : Start the containers] **********************************************************************************************************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n File \”/tmp/ansible_docker_compose_payload_sQH9KA/ansible_docker_compose_payload.zip/ansible/modules/cloud/docker/docker_compose.py\”, line 482, in \nImportError: No module named compose\n”}

PLAY RECAP ******************************************************************************************************************************************************************************
localhost : ok=11 changed=0 unreachable=0 failed=1 skipped=95 rescued=0 ignored=0

vravind
Guest
4 years ago

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: SyntaxError: invalid syntax
fatal: [localhost]: FAILED! => {“changed”: false, “module_stderr”: “Traceback (most recent call last):\n File \”/root/.ansible/tmp/ansible-tmp-1578309070.85-243878990646741/AnsiballZ_docker_compose.py\”, line 102, in \n _ansiballz_main()\n File \”/root/.ansible/tmp/ansible-tmp-1578309070.85-243878990646741/AnsiballZ_docker_compose.py\”, line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \”/root/.ansible/tmp/ansible-tmp-1578309070.85-243878990646741/AnsiballZ_docker_compose.py\”, line 40, in invoke_module\n runpy.run_module(mod_name=’ansible.modules.cloud.docker.docker_compose’, init_globals=None, run_name=’__main__’, alter_sys=True)\n File \”/usr/lib64/python2.7/runpy.py\”, line 176, in run_module\n fname, loader, pkg_name)\n File \”/usr/lib64/python2.7/runpy.py\”, line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File \”/usr/lib64/python2.7/runpy.py\”, line 72, in _run_code\n exec code in run_globals\n File \”/tmp/ansible_docker_compose_payload_MImJMr/ansible_docker_compose_payload.zip/ansible/modules/cloud/docker/docker_compose.py\”, line 483, in \n File \”/usr/lib/python2.7/site-packages/compose/cli/command.py\”, line 12, in \n from .. import config\n File \”/usr/lib/python2.7/site-packages/compose/config/__init__.py\”, line 6, in \n from .config import ConfigurationError\n File \”/usr/lib/python2.7/site-packages/compose/config/config.py\”, line 50, in \n from .validation import match_named_volumes\n File \”/usr/lib/python2.7/site-packages/compose/config/validation.py\”, line 12, in \n from jsonschema import Draft4Validator\n File \”/usr/lib/python2.7/site-packages/jsonschema/__init__.py\”, line 33, in \n import importlib_metadata as metadata\n File \”/usr/lib/python2.7/site-packages/importlib_metadata/__init__.py\”, line 9, in \n import zipp\n File \”/usr/lib/python2.7/site-packages/zipp.py\”, line 12, in \n import more_itertools\n File \”/usr/lib/python2.7/site-packages/more_itertools/__init__.py\”, line 1, in \n from .more import * # noqa\n File \”/usr/lib/python2.7/site-packages/more_itertools/more.py\”, line 460\n yield from iterable\n ^\nSyntaxError: invalid syntax\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}

please inform how to fix this error

Vijesh
Vijesh
Guest
4 years ago

Great article!

A Whitaker
A Whitaker
Guest
4 years ago

Still not able to get this working. Receiving following error:

TASK [local_docker : Start the containers] **************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “Failed to import docker or docker-py (Docker SDK for Python) – No module named docker. Try `pip install docker` or `pip install docker-py` (Python 2.6).”}

Anuradha P. Dhanashetti
Anuradha P. Dhanashetti
Guest
4 years ago

Hi,
following the instructions, I installed AWX, but what credentials should I enter to log in.
Subscription to Ansible is required compulsory?
Please guide.

Antonio
Antonio
Guest
4 years ago

I found in another site that some commands to run this with SELINUX enabled :
semanage port -a -t http_port_t -p tcp 8051
semanage port -a -t http_port_t -p tcp 8052
setsebool -P httpd_can_network_connect 1
*** I will use this guide with SELINUX enbled and we will see if this works — I will post here

Rifki Affandi
Guest
4 years ago

TASK [local_docker : Start the containers] ************************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “Cannot have both the docker-py and docker python modules (old and new version of Docker SDK for Python) installed together as they use the same namespace and cause a corrupt installation. Please uninstall both packages, and re-install only the docker-py or docker python module (for awx’s Python /bin/python). It is recommended to install the docker module if no support for Python 2.6 is required. Please note that simply uninstalling one of the modules can leave the other module in a broken state.”}

htinaung
htinaung
Guest
4 years ago

TASK [local_docker : Start the containers] ******************************************
fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “Cannot have both the docker-py and docker python modules (old and new version of Docker SDK for Python) installed together as they use the same namespace and cause a corrupt installation. Please uninstall both packages, and re-install only the docker-py or docker python module. It is recommended to install the docker module if no support for Python 2.6 is required. Please note that simply uninstalling one of the modules can leave the other module in a broken state.”}

PLAY RECAP **************************************************************************
localhost : ok=8 changed=0 unreachable=0 failed=1 skipped=77 rescued=0 ignored=0

[root@ansible01 installer]#

Chris
Chris
Guest
5 years ago

Good guide, Issue I’m having with the awx installer:
TASK [local_docker : Start the containers] *****************************************************************************************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “errors”: [], “module_stderr”: “”, “module_stdout”: “”, “msg”: “Error starting project 500 Server Error: Internal Server Error (\”Get https://registry-1.docker.io/v2/: dial tcp 52.22.67.152:443: connect: connection refused\”)”}

Why is awx trying to install this image? I am behind a proxy

sarsi
sarsi
Guest
5 years ago

unable to install
TASK [local_docker : Start the containers] **************************************************************************************************************************************************************************************************
task path: /var/tmp/awx/installer/roles/local_docker/tasks/compose.yml:25
fatal: [localhost]: FAILED! => {“changed”: false, “msg”: “Failed to import docker or docker-py – cannot import name UnrewindableBodyError. Try `pip install docker` or `pip install docker-py` (Python 2.6)”}
to retry, use: –limit @/var/tmp/awx/installer/install.retry

Francesco
Francesco
Guest
5 years ago

Great!

Coderdba
Guest
5 years ago

Great!!

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

2
0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.