The term "ansible" was coined by Ursula K. Le Guin in her 1966 novel Rocannon's World, and refers to fictional instantaneous communication systems.
The Ansible tool was developed by Michael DeHaan, the author of the provisioning server application Cobbler and co-author of the Fedora Unified Network Controller (Func) framework for remote administration.
Ansible, Inc. (originally AnsibleWorks, Inc.) was the company set up to commercially support and sponsor Ansible. Red Hat acquired Ansible in October 2015.
Ansible is included as part of the Fedora distribution of Linux, owned by Red Hat, and is also available for Red Hat Enterprise Linux, CentOS, openSUSE, SUSE Linux Enterprise, Debian, Ubuntu, Scientific Linux, and Oracle Linux via Extra Packages for Enterprise Linux (EPEL), as well as for other operating systems.
Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows. It includes its own declarative language to describe system configuration. Ansible is agentless, temporarily connecting remotely via SSH or Windows Remote Management (allowing remote PowerShell execution) to do its tasks.
The following Tutorial will take you through installing AWX the community version of Ansible Tower on Ubuntu 18.04. In this example the Docker Compose version of AWX will be used
Minimum Spec Machine
- Ubuntu 20.04|18.04 LTS Server (This tutorial focuses on 18.04)
- At least 4GB of RAM – More is better
- 2vcpus – More is better
- 10GB free disk storage - More is better
- root or user with sudo for ssh
- Open port: 80, 8000,9000
Install Docker
As always update
sudo apt -y update
Install some prerequites for Docker
sudo apt -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common git
Remove any older versions of Docker
sudo apt remove docker docker-engine docker.io containerd runc
Import the GPG Key for Docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
We need to add the Docker-CE Repos for Ubuntu
Note on the first line the - at the end
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
Update
sudo apt update
Install Docker-CE and additional software
sudo apt install docker-ce docker-ce-cli containerd.io
Add your user to the docker user group
sudo usermod -aG docker $USER
newgrp docker
Check Docker Version installed
docker version
Should read something like this
Client: Docker Engine - Community
Version: 19.03.10
API version: 1.40
Go version: go1.13.10
Git commit: 9424aeaee9
Built: Thu May 28 22:16:49 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.10
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 9424aeaee9
Built: Thu May 28 22:15:20 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Docker is installed
Install Docker Compose
The version of docker compose in the repos is not the latest version to install the latest version we need to run some additional commands
Note: Copy all of this
curl -s https://api.github.com/repos/docker/compose/releases/latest \
| grep browser_download_url \
| grep docker-compose-Linux-x86_64 \
| cut -d '"' -f 4 \
| wget -qi -
Make the file executable
chmod +x docker-compose-Linux-x86_64
Move the file into somewhere in the path
sudo mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
or move the file into /opt and symlink it to a path location
sudo mkdir /opt/docker
sudo mv docker-compose-Linux-x86_64 /opt/docker/docker-compose
sudo ln -s /opt/docker/docker-compose /usr/local/bin/docker-compose
Check the Version Number
docker-compose version
It should look something like this
docker-compose version 1.25.5, build unknown
docker-py version: 4.2.0
CPython version: 3.6.9
OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
We will need to make a note of the version number for later
Docker Compose is installed
GUI For Docker Management (Optional)
I've included instructions for Portainer here as I find it the simplest way of managing my Docker Containers, all of which can be done from the command line. As a busy sysadmin I like quick solutions as i'm learning longer term commands.
On the same machine you've just installed Docker and docker-compose on run the following
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
you can now access Portainer using
http://<ip of machine>:9000
You'll be asked to create an admin user
You will then be asked which environment your docker is running on, in this case choose Local
This will take you to the main Portainer Dashboard
Navigate around to see Containers or the Networks
Install Prerequisites for AWX
There are some prereqs we need to install
Ansible
Install Ansible from the Ansible PPA
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main" | sudo tee /etc/apt/sources.list.d/ansible.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
Install
sudo add-apt-repository ppa:ansible/ansible-2.9
sudo apt update
sudo apt update
sudo apt install -y ansible
sudo apt install -y ansible
Check the installed version
ansible --version
Should read
ansible 2.9.9
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/david/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]
Ansible is installed
Node.JS and NPM
Many tutrials give the wrong command here , on 18.04 when you install node, npm installs automatically
sudo apt install -y nodejs
sudo apt install npm
docker-py python module
Install the correct version
sudo apt install python3-pip git pwgen vim
sudo pip3 install requests==2.14.2
Check the version of Docker Compose
docker-compose version
Looking for the line which reads
docker-compose version 1.25.5, build 4667896
Upgrade pip3 and Install the docker compose python module
pip3 install --upgrade pip cffi && \
pip3 install ansible && \
pip3 install mitogen ansible-lint && \
pip3 install --upgrade pywinrm
sudo pip3 install docker-compose==1.25.5
Install AWX
The installation of AWX is done using an Ansible playbook which can be pulled down from the Ansible AWX git repo
Pull down the code from git
sudo su -
sudo su -
pull down the git repo
git clone --depth 1 --branch 17.1.0 https://github.com/ansible/awx.git
Navigate to the Install directory
cd awx/installer/
Generate a strong secret
We need to generate a strong secret for the inventory file
pwgen -N 1 -s 30
should generate something random like this
FwAFoVz17XFWAJMKJQqbtC7DeYDYly
Edit the Inventory
The Ansible inventory needs to be updated
vi inventory
Change the following lines
postgres_data_dir=/home/pgdocker
docker_compose_dir=/home/awxcompose
admin_password=StrongAdminpasswordforWebInterface
secret_key=FwAFoVz17XFWAJMKJQqbtC7DeYDYly
postgres_data_dir=/home/pgdocker
docker_compose_dir=/home/awxcompose
admin_password=StrongAdminpasswordforWebInterface
secret_key=FwAFoVz17XFWAJMKJQqbtC7DeYDYly
add the following to the end of the file
rabbitmq_password=awxpass
rabbitmq_erlang_cookie=cookiemonster
Run the playbook
Run the following command
ansible-playbook -i inventory install.yml
The install should run through, if it doesn't i've put some troubleshooting tips below
The install takes no longer than 5 minutes
Once complete you can access the Login page
http://serverip/
Troubleshooting
Install Issues
Note: Should you get an error when running the playbook / AWX Installrelating to the docker.py or docker compose python module please do the following
sudo apt remove docker-py
python3 -m pip install -U pip
sudo pip3 install docker-compose==1.25.5
or Reboot the server
sudo reboot
Post Install Issues
I and several others have noted that the first time you run the installer you get an AWX Updating screen which will try and refresh but will sit there for hours if you let it

Fix
cd /home/awxcompose/
docker-compose stop
cd ~/awx/installer
ansible-playbook -i inventory install.yml
cd /home/awxcompose/
docker-compose stop
cd ~/awx/installer
ansible-playbook -i inventory install.yml
When you head back to http://your awx ip/
You will still see the updating screen

However in less than 5 minutes on my test system I got the login screen

No comments:
Post a Comment