Ansible administration is most often done from the command line. Make that task a bit more efficient with the help of the web-based GUI, AWX.
If you’re an Ansible admin, you’re probably well-versed in the ways of the command line interface (CLI). But there may be times when you long to have a nice GUI to make your admin job a bit easier.
That’s where Ansible Web eXecutable (AWX) comes into play. AWX is a free/open source project that allows you to more easily manage your Ansible projects. AWX provides:
-
A web-based interface
-
Tax engine built on top of Ansible
-
A powerful REST API
-
The ability to manage or sync inventory with other cloud services
-
The ability to control access
-
Integration with LDAP
I’m going to show you how to install this powerful web GUI on CentOS 8.
What you’ll need
-
A running/updated instance of CentOS 8
-
A user with sudo privileges
How to install the AWX dependencies
The first thing to take care of is the installation of the dependencies. Log in to your CentOS 8 server, open a terminal window, and issue the following commands:
sudo dnf install epel-release -y sudo dnf install git gcc gcc-c++ ansible nodejs gettext device-mapper-persistent-data lvm2 bzip2 python3-pip -y
How to install Docker and Docker Compose
We now need to install both Docker and Docker Compose. The first thing to do is add the necessary repository with the command:
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Once the repository is added, install the latest version of Docker with the command:
sudo dnf install docker-ce-3:18.09.1-3.el7 -y
Start and enable the Docker engine with the commands:
sudo systemctl start docker sudo systemctl enable docker
Add your user to the docker group with the command:
sudo usermod -aG docker $USER
Log out and log back in.
Install docker-compose via pip3 with the command:
sudo pip3 install docker-compose
Finally, set python to use Python 3 with the command:
alternatives --set python /usr/bin/python3
How to install AWX
Now we can finally install AWX. Clone the latest release with the command:
git clone https://github.com/ansible/awx.git
Next, generate a secret encryption key with the command:
openssl rand -base64 30
Copy the key that is generated to your clipboard.
Change into the newly downloaded AWX directory with the command:
cd awx/installer
Open the AWX inventory file with the command:
nano inventory
In that file, you’ll need to (at a minimum), edit the following configuration options. First, locate the line:
secret_key=
In that line, paste the secret key you generated earlier.
Next, look for the line:
admin_password=password
Change the password to a strong, unique password.
Finally, look for the line that starts with:
#awx_alternate_dns_servers=
Change that line to:
awx_alternate_dns_servers="8.8.8.8,8.8.4.4"
You can then go through the rest of the inventory file and edit as needed. But, the above changes should result in a successful installation.
Create a directory for Postgres with the command:
sudo mkdir /var/lib/pgdocker
Install AWX with the command:
sudo ansible-playbook -i inventory install.yml
This should take about five to10 minutes to complete.
How to modify SELinux and the CentOS firewall
Before we can access the AWX site, we need to disable SELinux. Issue the command:
sudo nano /etc/sysconfig/selinux
Change the line:
SELINUX=enforcing
To:
SELINUX=disabled
Save and close the file. Restart your system so the changes will take effect.
The last step is to modify the firewall. This is done with the following commands:
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
Finally, open a web browser and point it to http://SERVER_IP (where SERVER_IP is the IP address of your hosting server). You will be greeted by the AWX login screen, where you’ll use the admin username and the password you set in the admin_password configuration (Figure A).
Figure A
Once you authenticate, you’ll find yourself in the AWX dashboard, where you can begin working with Ansible through this user-friendly web-based GUI (Figure B).
Figure B
Congratulations, working with Ansible should now be a bit easier.
This article has been published from a wire agency feed without modifications to the text. Only the headline has been changed.