Ansible AWX is a free and open-source web application sponsored by Red Hat that allows you to manage Ansible playbooks and inventories. It provides a web-based interface that makes Ansible more comfortable to use in an IT environment. It also provides a REST API that helps you to control access, and graphically manage or sync inventory with a wide variety of cloud sources.

This tutorial will show you how to install Ansible AWX software on Debian 11.

Prerequisites

  • A server running Debian 11.
  • A root password is configured on the server.

Add Ansible Repository

The Ansible package is not included in the Debian 11 default repository by default. So you will need to add the Ansible repository on your server.

First, install all the required dependencies using the following command:

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

Once all the dependencies are installed, edit the sources.list file and add the Ansible repository:

nano /etc/apt/sources.list

Add the following line:

deb http://ppa.launchpad.net/ansible/ansible/ubuntu focal main

Save and close the file then add the GPG key with the following command:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367

You will get the following output:

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.47eo2M3Kib/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
gpg: key 93C4A3FD7BB9C367: public key "Launchpad PPA for Ansible, Inc." imported
gpg: Total number processed: 1
gpg:               imported: 1

Next, update the repository cache using the following command:

apt-get update -y

Install Ansible on Debian 11

Now, run the following command to install Ansible using the following command:

apt-get install ansible -y

Once the Ansible has been installed, verify the Ansible version with the following command:

ansible --version

You will get the following output:

ansible [core 2.11.6] 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 2.11.3
  libyaml = True

Once you are finished, you can proceed to the next step.

Install Docker CE

By default, the latest version of Docker CE is not included in the Debian 11 default repository. So you will need to add it to the APT.

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

curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Next, add the Docker CE repository to the APT with the following command:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list

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

apt-get update -y

apt-get install docker-ce -y

Once the installation is completed, verify the status of the Docker using the following command:

systemctl status docker

You will get the following output:

? docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2021-11-01 04:59:11 UTC; 26min ago
TriggeredBy: ? docker.socket
       Docs: https://docs.docker.com
   Main PID: 5066 (dockerd)
      Tasks: 32
     Memory: 1.0G
        CPU: 1min 57.723s
     CGroup: /system.slice/docker.service
             ?? 5066 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
             ??21970 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.18.0.2 -container-port 8052
             ??21994 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 80 -container-ip 172.18.0.2 -container-port 8052

Nov 01 04:59:11 debian11 dockerd[5066]: time="2021-11-01T04:59:11.756163493Z" level=info msg="Docker daemon" commit=e2f740d graphdriver(s)=ove>
Nov 01 04:59:11 debian11 dockerd[5066]: time="2021-11-01T04:59:11.756303194Z" level=info msg="Daemon has completed initialization"
Nov 01 04:59:11 debian11 systemd[1]: Started Docker Application Container Engine.
Nov 01 04:59:11 debian11 dockerd[5066]: time="2021-11-01T04:59:11.796631663Z" level=info msg="API listen on /run/docker.sock"

To verify the Docker version, run the following command:

docker -v

You should see the following output:

Docker version 20.10.10, build b485636

Once you are finished, you can proceed to the next step.

Install Docker Compose and Other Dependency

First, download the Docker Compose binary from the Git repository using the following command:

wget https://github.com/docker/compose/releases/download/1.29.0/docker-compose-Linux-x86_64

Next, move the downloaded binary to the /usr/bin/ directory:

mv docker-compose-Linux-x86_64 /usr/bin/docker-compose

Next, set the executable permission to the docker-compose binary:

chmod  x /usr/bin/docker-compose

Next, verify the Docker Compose version using the command below:

docker-compose version

You will get the following output:

docker-compose version 1.29.0, build 07737305
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

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

apt-get install nodejs npm -y

npm install npm --global

Next, install the PIP and other dependencies using the following command:

apt-get install python3-pip git pwgen -y

Next, install the Python module for Docker Compose with the following command:

pip3 install docker-compose==1.29.0

Once you are finished, you can proceed to the next step.

Install Ansible AWX

First, download the Ansible AWX from the Git Hub repository using the following command:

wget https://github.com/ansible/awx/archive/17.1.0.zip

Once the download is completed, unzip the downloaded file with the following command:

unzip 17.1.0.zip

Next, change the directory to the extracted directory and generate a secrete key using the following command:

cd awx-17.1.0/installer/

pwgen -N 1 -s 30

You will get the following output:

dGF8eiFiTkzpaqpWyckxSLe57sZNfJ

Next, edit the inventory file and define your secrete key, admin username and password:

nano inventory

Change the following lines:

admin_user=admin
admin_password=securepassword
secret_key=dGF8eiFiTkzpaqpWyckxSLe57sZNfJ

Save and close the file then run the Ansible playbook to install the Ansible AWX:

ansible-playbook -i inventory install.yml

Once the Ansible AWX is installed, you will get the following output:

TASK [local_docker : Create Redis socket directory] *******************************************************************************************
changed: [localhost]

TASK [local_docker : Create Docker Compose Configuration] *************************************************************************************
changed: [localhost] => (item={'file': 'environment.sh', 'mode': '0600'})
changed: [localhost] => (item={'file': 'credentials.py', 'mode': '0600'})
changed: [localhost] => (item={'file': 'docker-compose.yml', 'mode': '0600'})
changed: [localhost] => (item={'file': 'nginx.conf', 'mode': '0600'})
changed: [localhost] => (item={'file': 'redis.conf', 'mode': '0664'})

TASK [local_docker : Render SECRET_KEY file] **************************************************************************************************
changed: [localhost]

TASK [local_docker : Remove AWX containers before migrating postgres so that the old postgres container does not get used] ********************
ok: [localhost]

TASK [local_docker : Run migrations in task container] ****************************************************************************************
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]

TASK [local_docker : Wait for launch script to create user] ***********************************************************************************
ok: [localhost -> localhost]

TASK [local_docker : Create Preload data] *****************************************************************************************************
changed: [localhost]

PLAY RECAP ************************************************************************************************************************************
localhost                  : ok=21   changed=12   unreachable=0    failed=0    skipped=73   rescued=0    ignored=1   

The above playbook will download some Docker images and create an Ansible AWX container.

To verify all Docker images, run:

docker images

You should see the following output:

REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
postgres      12        108ccc7c5fa3   5 days ago     371MB
redis         latest    7faaec683238   2 weeks ago    113MB
centos        8         5d0da3dc9764   6 weeks ago    231MB
ansible/awx   17.1.0    599918776cf2   7 months ago   1.41GB

To verify all running containers, run:

docker ps

You should see the following output:

CONTAINER ID   IMAGE                COMMAND                  CREATED         STATUS         PORTS                                   NAMES
b6cd8d874b09   ansible/awx:17.1.0   "https://www.howtoforge.com/usr/bin/tini -- /u…"   2 minutes ago   Up 2 minutes   8052/tcp                                awx_task
65dd0c36334a   ansible/awx:17.1.0   "https://www.howtoforge.com/usr/bin/tini -- /b…"   5 minutes ago   Up 2 minutes   0.0.0.0:80->8052/tcp, :::80->8052/tcp   awx_web
4119ca4a1d24   postgres:12          "docker-entrypoint.s…"   5 minutes ago   Up 2 minutes   5432/tcp                                awx_postgres
212b73bfe362   redis                "docker-entrypoint.s…"   5 minutes ago   Up 2 minutes   6379/tcp                                awx_redis

Access Ansible AWX

Now, open your web browser and access the Ansible AWX web interface using the URL http://your-server-ip. You should see the Ansible AWX login page:

<img alt="Ansible AWX Login" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/02/echo/p1.png63f915641adad.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="378" loading="lazy" src="data:image/svg xml,” width=”750″>

Provide your admin username, password and click on the Login button. You should see the Ansible AWX dashboard on the following screen:

<img alt="Ansible AWX" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/02/echo/p2.png63f915643cee6.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="372" loading="lazy" src="data:image/svg xml,” width=”750″>

Congratulations! you have successfully installed Ansible AWX on Debian 11.