Quantcast
Channel: Tech Support
Viewing all articles
Browse latest Browse all 880

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

$
0
0
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.


Prerequisites

To follow this guide along, you will need one (physical or virtual) machine with CentOS/RHEL 7/8 minimal installed having a non-root user sudo 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 under a Docker container:
sudo nano /etc/sysconfig/selinux
Find the following line and replace the value "enforcing" with "disabled":
SELINUX=disabled
Save and close the file.

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/REHL 8:
sudo dnf -y install epel-release
Type below command if you are running CentOS/RHEL 7:
sudo yum -y install epel-release
Next, install following additional dependencies on your CentOS/RHEL using the below command:

Type below on CentOS/RHEL 8:
sudo dnf -y install git gcc gcc-c++ ansible nodejs gettext device-mapper-persistent-data lvm2 bzip2 python3-pip
Type below on CentOS/RHEL 7:
sudo yum -y install git gcc gcc-c++ ansible nodejs gettext device-mapper-persistent-data lvm2 bzip2 python3-pip nano

Install Docker

In this section, we will install Docker and Docker Compose to run Ansible AWX inside a Docker container:

Type below to add Docker repository on CentOS/RHEL 8:
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Type below command to install Docker on CentOS/RHEL 8:
sudo dnf -y install docker-ce
Type below to create Docker repository on CentOS/RHEL 7:
sudo vi /etc/yum.repos.d/docker-ce.repo
Add following contents:
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://download.docker.com/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://download.docker.com/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://download.docker.com/linux/centos/7/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
Save and close the file.

Type below to install Docker on CentOS/RHEL 7:
sudo yum -y install docker-ce
Next, start the Docker service and make it persistent on system reboot with below command:
sudo systemctl start docker
sudo systemctl enable docker
Confirm that docker is active and running:
sudo 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
Once you are finished with docker and docker compose installation, type the below command to set python 3 in environment variable:
sudo alternatives --set python /usr/bin/python3

Download Ansible AWX

You can download Ansible AWX latest release from the Git Hub repository using the below command:
cd ~
git clone https://github.com/ansible/awx.git
When download complete, generate a secret key using openssl 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/
sudo nano inventory
Replace the following values with yours:
[all:vars]
dockerhub_base=ansible
awx_task_hostname=awx
awx_web_hostname=awxweb
postgres_data_dir="/var/lib/pgdocker"
host_port=80
host_port_ssl=443
docker_compose_dir="~/.awx/awxcompose"
pg_username=awx
pg_password=awxpass
pg_database=awx
pg_port=5432
pg_admin_password=password
rabbitmq_password=awxpass
rabbitmq_erlang_cookie=cookiemonster
admin_user=admin
admin_password=password
create_preload_data=True
secret_key=Paste_Your_Secret_Key_Here
awx_official=true
awx_alternate_dns_servers="8.8.8.8,8.8.4.4"
project_data_dir=/var/lib/awx/projects
Save and close the file when you are finished.

Next, create a pgdocker directory under /var/lib/
sudo mkdir /var/lib/pgdocker
Type the following command to install AWX:
sudo ansible-playbook -i inventory install.yml
Upon successful installation, you will see output similar to the following:

This will create and start all the required Docker containers for Ansible AWX.

You can verify the running containers with the following command:
sudo docker ps
You will see output similar to the following:

Add Firewall Rules

You will need to add following rules to allow http and https service to pass through firewalld:
sudo firewall-cmd --zone=public --add-masquerade --permanent
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo 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 AWX login page like below:

IMAGE HERE

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

IMAGE HERE

Wrapping up

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

Viewing all articles
Browse latest Browse all 880

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>