Atlantic.Net Blog

How to Install Ansible AWX on Debian 10

Hitesh Jethva
by Atlantic.Net (86posts) under VPS Hosting
0 Comments

Ansible is a free and open-source configuration management and automation tool used to manage hundreds and thousands of servers from a central location.

Ansible AWX is an open-source project, sponsored by Red Hat, that helps you control Ansible in IT environments. It provides a web-based interface REST API and task engine for Ansible. You can manage playbooks, secrets, inventories, and cron jobs using the AWX web-based interface.

In this tutorial, we will show you how to install Ansible AWX with Docker on Debian 10.

Prerequisites

  • A fresh Debian 10 VPS on the Atlantic.net Cloud Platform
  • A root password configured on your server

Step 1 – Create an Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server.  Create a new server, choosing Debian 10 as the operating system, with at least 4GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your Debian 10 server, run the following command to update your base system with the latest available packages.

apt-get update -y

Step 2 – Install Docker

First, you will need to install the Docker and Docker compose in your system. By default, the latest version of Docker is not available in the Debian standard repository, so you will need to add the Docker repository to your system.

Install the required dependencies with the following command:

apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y

Next, download and add the Docker GPG key with the following command:

curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -

Next, add the Docker repository with the following command:

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

Next, update the Docker repository and install Docker with Docker compose using the following command:

apt-get update -y
apt-get install docker-ce docker-compose -y

Once both packages are installed, verify the installed version of Docker with the following command:

docker --version

You should get the following output:

Docker version 19.03.13, build 4484c46d9d

Step 2 – Install Ansible

AWX is built on the top of the Ansible. so you will need to install Ansible in your system.

First, add the Ansible repository with the following command:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main" | tee /etc/apt/sources.list.d/ansible.list

Next, update the repository and install the Ansible with the following command:

apt-get update -y
apt-get install ansible -y

Once the Ansible is installed, verify the installed version of Ansible using the following command:

ansible --version

You should get the following output:

ansible 2.9.13
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.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.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0]

Step 3 – Install Node.js and Python Library

First, install the Node.js, NPM and Git with the following command:

apt-get install nodejs npm git -y
npm install npm --global

Next, install the Python module for Docker and other required dependencies with the following command:

apt-get install python3-pip pwgen python3-docker -y
pip3 install requests==2.14.2

Next, update the default Python version with the following command:

update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3 2

Next, you will need to install Docker compose Python module in your system.

First, check the installed version of Docker compose with the following command:

docker-compose version

You should get the following output:

docker-compose version 1.21.0, build unknown
docker-py version: 3.4.1
CPython version: 3.7.3
OpenSSL version: OpenSSL 1.1.1d  10 Sep 2019

Next, installed the matching version of Docker compose Python module with the following command:

pip3 install docker-compose==1.21.0

Step 4 – Install Ansible AWX

First, download the latest version of AWX source from the Git repository using the following command:

git clone --depth 50 https://github.com/ansible/awx.git

Once downloaded, change the directory to awx and generate the secrete key with the following command:

cd awx/installer/
pwgen -N 1 -s 30

You should get the following output:

4NaNkNcMBOj4Jxp4fWi91mymuW9TbR

Next, create a new inventory file with the following command:

nano inventory

Add the following lines including, admin user, password, secret key, port, and hostname as shown below:

dockerhub_base=ansible
awx_task_hostname=awx
awx_web_hostname=awxweb
postgres_data_dir=/tmp/pgdocker
host_port=80
host_port_ssl=443
docker_compose_dir=/tmp/awxcompose
pg_username=awx
pg_password=awxpass
pg_database=awx
pg_port=5432
admin_user=admin
admin_password=adminpassword
create_preload_data=True
secret_key=2fCkx2K5GnIjBz4OterhOC3ey0WPdj

Save and close the file when you are finished.

Next, run the playbook to install the Ansible AWX with the following command:

ansible-playbook -i inventory install.yml

Once the Ansible AWX has been installed, you should get the following output:

TASK [local_docker : Create Docker Compose Configuration] *************************************************************************************
changed: [localhost] => (item={u'mode': u'0600', u'file': u'environment.sh'})
changed: [localhost] => (item={u'mode': u'0600', u'file': u'credentials.py'})
changed: [localhost] => (item={u'mode': u'0600', u'file': u'docker-compose.yml'})
changed: [localhost] => (item={u'mode': u'0600', u'file': u'nginx.conf'})
changed: [localhost] => (item={u'mode': u'0664', u'file': u'redis.conf'})
TASK [local_docker : Render SECRET_KEY file] **************************************************************************************************
changed: [localhost]
TASK [local_docker : Start the containers] ****************************************************************************************************
changed: [localhost]
TASK [local_docker : Update CA trust in awx_web container] ************************************************************************************
changed: [localhost]
TASK [local_docker : Update CA trust in awx_task container] ***********************************************************************************
changed: [localhost]
PLAY RECAP ************************************************************************************************************************************
localhost                  : ok=15   changed=7    unreachable=0    failed=0    skipped=86   rescued=0    ignored=0  

Next, you can verify the list of running containers using the following command:

docker ps

You should get the following output:

CONTAINER ID        IMAGE                COMMAND                  CREATED              STATUS              PORTS                  NAMES
167d008ee26f        ansible/awx:14.1.0   "/usr/bin/tini -- /u…"   About a minute ago   Up About a minute   8052/tcp               awx_task
260c028bf07d        ansible/awx:14.1.0   "/usr/bin/tini -- /b…"   About a minute ago   Up About a minute   0.0.0.0:80->8052/tcp   awx_web
e15d5ee1c940        postgres:10          "docker-entrypoint.s…"   About a minute ago   Up About a minute   5432/tcp               awx_postgres
6472ee690066        redis                "docker-entrypoint.s…"   About a minute ago   Up About a minute   6379/tcp               awx_redis

Step 5 – Access Ansible AWX Dashboard

Now, open your web browser and access the Ansible AWX dashboard using the URL http://your-server-ip. You will be redirected to the AWX login page:

Provide your admin username and password that you have defined in the inventory file and click on the SIGN IN button. You should see the Ansible AWX dashboard on the following page:

Conclusion

Congratulations! You have successfully installed Ansible AWX with Docker on Debian 10. You can now easily control Ansible inventory, secrets, playbooks, and more from the AWX dashboard; try it now on VPS Hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G2.1GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G2.1GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources