This topic is about how to install Ansible AWX on Docker Compose.
Nowadays the most applications are container-based design, Ansible AWX has support to multiple deployment types such as OpenShift, Kubernetes, Minishift, and Docker Compose.
- Concepts
- System Requirements
- Prerequisites
- Setup Docker
- Setup Firewall
- Download and Setup AWX
- Summary
- References
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. To learn more about all the features of Compose, see the list of features. 1
The system requirements for Ansible AWX deployment on Docker Compose. 2
- At least 4GB of memory;
- At least 2 cpu cores;
- At least 20GB of space.
Install docker-ce repository.
curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
Install EPEL repository.
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Install packages.
dnf -y install python3-pip git docker-ce ansible --nobest
Install docker-compose.
pip3 install docker-compose
Enable and start docker service.
systemctl enable --now docker
Create a exclusive network for Docker Compose.
docker network create --opt com.docker.network.bridge.name=awxcompose0 awxcompose
Allow the following firewall policies.
firewall-cmd --zone=trusted --add-interface=awxcompose0 --permanent
firewall-cmd --zone=trusted --add-interface=awxcompose0
firewall-cmd --add-service=http --add-service=https --permanent
firewall-cmd --add-service=http --add-service=https
Get AWX source code.
git clone https://github.com/ansible/awx
Change directory.
cd awx/installer/
Define Docker Compose network to be used by template.
cat << EOF >> roles/local_docker/templates/docker-compose.yml.j2
networks:
default:
external:
name: awxcompose
EOF
Define AWX admin password.
sed -E -i 's|^(#)?admin_password=.*|admin_password=mypassword|g' inventory
Create SSL certificate.
mkdir -vp ~/.awx/ssl
openssl req -subj \
'/C=BR/ST=Sao Paulo/L=Sao Paulo/O=AWX Example/OU=IT/CN=awx.example.com/[email protected]' \
-new -nodes -x509 -days 365 -newkey rsa:2048 \
-keyout ~/.awx/ssl/awx.key \
-out ~/.awx/ssl/awx.crt
cat ~/.awx/ssl/awx.crt ~/.awx/ssl/awx.key >> ~/.awx/ssl/awx.pem
Adjust inventory for SSL certificate.
sed -E -i 's|^(#)?ssl_certificate=.*|ssl_certificate="~/.awx/ssl/awx.pem"|g' inventory
You can adjust other parameters, check inventory file. By default the user's home directory is the default path for storing container files, as well as for the PostgreSQL database.
grep -Ev '^$|^#' inventory
Run Ansible Playbook to configure AWX.
ansible-playbook -i inventory -e ansible_python_interpreter=python3 install.yml
Wait for playbook to finish.
While containers are initializing, index page remains in status "AWX is Upgrading", that page will be automatically refreshed and redirected to login page, then it will be able to accept user credentials.
NOTE: it's strongly recommended to use Safari or Firefox browsers, recent Chrome version does not work due self-signed certificate.
In this topic was presented:
- Installing AWX prerequisites;
- Download and setup Ansible AWX for Docker Compose deployment on CentOS 8.
[1] - https://docs.docker.com/compose/
[2] - https://github.com/ansible/awx/blob/devel/INSTALL.md
Next topic: Managing AWX using REST API, CLI and Web UI