Install AWX or Ansible Tower without Docker on CentOS7

Ansible Tower (formerly ‘AWX’) is a web-based solution that makes Ansible even more easy to use for IT teams of all kinds. It’s designed to be the hub for all of your automation tasks.

Installation

There are quite a few good scripts that are already circulating around. This script resolves a few issues with the others I have seen.  I have commented out the three semanage port lines for port 8050-8052 as I am not 100% certain that this action is needed, but when in doubt use them at will.

# Before you begin
yum -y update

# SELinux
yum -y install policycoreutils-python
# semanage port -a -t http_port_t -p tcp 8050
# 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

# Firewalld
yum -y install firewalld
systemctl enable --now firewalld
# reboot if firewalld was not present to resolve a dbus error
firewall-cmd --permanent --add-service={http,https}
firewall-cmd --reload

#################################################################
# Repos
#################################################################

# Epel / Software Collections Repositories:
yum -y install epel-release wget
yum -y install centos-release-scl centos-release-scl-rh

# AWX Repository
cat << 'EOF' | tee /etc/yum.repos.d/ansible-awx.repo


# Copr repo for Ansible AWX
cat << 'EOF' | tee /etc/yum.repos.d/ansible-awx.repo
[mrmeee-ansible-awx]
name=Copr repo for ansible-awx owned by mrmeee
baseurl=https://copr-be.cloud.fedoraproject.org/results/mrmeee/ansible-awx/epel-7-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/mrmeee/ansible-awx/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1
EOF

# RabbitMQ and Erlang Repositories
cat << 'EOF' | tee /etc/yum.repos.d/rabbitmq.repo
[bintray-rabbitmq-rpm]
name=bintray-rabbitmq-rpm
baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.7.x/el/7/
gpgcheck=0
repo_gpgcheck=0
enabled=1
EOF

cat << 'EOF' | tee /etc/yum.repos.d/rabbitmq-erlang.repo
[bintray-rabbitmq-erlang-rpm]
name=bintray-rabbitmq-erlang-rpm
baseurl=https://dl.bintray.com/rabbitmq-erlang/rpm/erlang/21/el/7/
gpgcheck=0
repo_gpgcheck=0
enabled=1
EOF

#################################################################
# Installation
#################################################################

# Install RabbitMQ and Git
yum -y install rabbitmq-server rh-git29
systemctl enable --now rabbitmq-server

# Install PostgreSQL, Initialize db, and create AWX db and user
yum -y install rh-postgresql10
scl enable rh-postgresql10 "postgresql-setup initdb"
systemctl enable --now rh-postgresql10-postgresql
scl enable rh-postgresql10 'su postgres -c "createuser -S awx"'
scl enable rh-postgresql10 'su postgres -c "createdb -O awx awx"'

# Install memcached
yum -y install memcached
systemctl enable --now memcached

# Install and configure NGINX
yum -y install nginx
cp -p /etc/nginx/nginx.conf{,.org}
wget -O /etc/nginx/nginx.conf https://raw.githubusercontent.com/faudeltn/AnsibleTower-awx/master/ansible-awx-install/nginx.conf
systemctl start --now nginx

# Install Python and dependencies
yum -y install rh-python36
yum -y install --disablerepo='*' --enablerepo='mrmeee-ansible-awx, base' -x *-debuginfo rh-python36*

# Install AWX-RPM
yum -y install ansible-awx

# Initialize AWX
sudo -u awx scl enable rh-python36 rh-postgresql10 rh-git29 "GIT_PYTHON_REFRESH=quiet awx-manage migrate"
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'root@localhost', 'password')" | sudo -u awx scl enable rh-python36 rh-postgresql10 "GIT_PYTHON_REFRESH=quiet awx-manage shell"
sudo -u awx scl enable rh-python36 rh-postgresql10 rh-git29 "GIT_PYTHON_REFRESH=quiet awx-manage create_preload_data"

# Optional Sample Configuration
sudo -u awx scl enable rh-python36 rh-postgresql10 rh-git29 "GIT_PYTHON_REFRESH=quiet awx-manage provision_instance --hostname=$(hostname)"
sudo -u awx scl enable rh-python36 rh-postgresql10 rh-git29 "GIT_PYTHON_REFRESH=quiet awx-manage register_queue --queuename=tower --hostnames=$(hostname)"

# Enable and Start AWX
systemctl enable --now awx

Results

Logon as admin / password

Notes

During the installation, I made note of the database and log locations.

 * Initializing database in '/var/opt/rh/rh-postgresql10/lib/pgsql/data'
 * Initialized, logs are in /var/lib/pgsql/initdb_rh-postgresql10-postgresql.log

Source(s)

  • https://docs.ansible.com/ansible/2.5/reference_appendices/tower.html
  • https://awx.wiki/
  • https://github.com/faudeltn/AnsibleTower-awx/blob/master/ansible-awx-install/install-awx
  • http://yallalabs.com/devops/how-to-install-ansible-awx-without-docker-centos-7-rhel-7/