ansible

Ansible with DellEMC Storage: Part 5 – Get Started with Ansible Tower (Using AWX)

This blog is the continuation of Ansible with DellEMC storage multi-part blog. 

In this 5th part, we will discuss about Ansible Tower (using AWX) and how to install and configure the same.

Overview

In my posts till now you might noticed that I have only used command line option to run any Ansible commands. There’s a reason for that. By default, when you install Ansible it only installs Ansible Engine, which only has Ansible CLI option. This is where Ansible Tower comes in picture. Note that AWX is the open source project for Tower.

While Ansible Tower has many features, below are few features which are my personal favorites. Since data storage management operations can be data destructive, below features are the reasons I am highly recommending using Tower / AWX for automating storage tasks.

  • Web Interface – To manage Ansible using Web interface
  • REST API Support – To manage and integrate Ansible Tower in other platforms. For example – integrating Ansible Tower with Jenkins
  • Task Engine – To create scheduled job and centralized operations.
  • Role Based Access Control – To control Enterprise level access across different team member and limit their visibility to information. This will make sure only designated users are having access to critical data/tasks.

Installing Ansible Tower (using AWX)

Make sure that you’ve supported operating systems installed and running. In my case I am using CentOS V7 virtual machine

Prerequisites –

Make sure below packages are installed on your machine

  • Make sure you have set the selinux to permissive
    • sudo setenforce permissive
  • Ansible – min version 2.8+
    • yum install -y ansible
  • Docker – Recent version
    • yum install -y docker
  • Docker Python Module
    • Follow below steps for installing docker-compose
[root@dw-test-1 installer]# sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

[root@dw-test-1 installer]# sudo chmod +x /usr/local/bin/docker-compose

[root@dw-test-1 installer]# sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

[root@dw-test-1 installer]# docker-compose --version

Once all the prerequisites are in place run below tasks

  • Clone the Git AWX repository using below command
[root@dw-test-1 installer]# git clone https://github.com/ansible/awx.git

This will create awx directory. cd into the awx/installer directory.

[root@dw-test-1 installer]# cd awx/installer

This folder has inventory file which has all the AWX parameters. Most important details in this file are passwords which are needed for logging into the AWX post installation. Note that AWX supports installation on Kubernetes and Openshift as well. In this example we will be using docker-compose.

Most important parameters in inventory file are as mentioned below. In my case I created the vars.yml file with below inputs and used the same while running the installation.

[root@dw-test-1 installer]# cat vars.yml
admin_password: 'admin'
pg_password: 'admin'
secret_key: 'mysecret'

Once you’ve checked and verified all the parameters in the inventory file, go ahead and run below command.

[root@dw-test-1 installer]# ansible-playbook -i inventory install.yml -e @vars.yml

Note – I faced couple of errors which running this playbook. I suggest taking a look at this link if you face the same.

Once playbook execution is completed you can run below command to validate the installation.

[root@dw-test-1 installer]# docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                  NAMES
23b236356057        ansible/awx_task:10.0.0   "/tini -- /bin/sh ..."   6 minutes ago       Up 2 minutes        8052/tcp               awx_task
a23edc05283e        ansible/awx_web:10.0.0    "/tini -- /bin/sh ..."   6 minutes ago       Up 2 minutes        0.0.0.0:80->8052/tcp   awx_web
385de9d395da        postgres:10               "docker-entrypoint..."   6 minutes ago       Up 2 minutes        5432/tcp               awx_postgres
125b9e551823        redis                     "docker-entrypoint..."   2 hours ago         Up 2 minutes        6379/tcp               awx_redis
2a8ad285e2d5        memcached:alpine          "docker-entrypoint..."   2 hours ago         Up 2 minutes        11211/tcp              awx_memcached

At this point AWX is installed. It takes some time for container to start and configure the AWX. Run the below command and wait till the time you see similar output

[root@dw-test-1 installer]# docker logs -f awx_task
...
2020-04-12 12:23:18,458 DEBUG    awx.main.dispatch task 7b92a5a8-efa9-4b5e-8dc7-d4ca1d974508 starting awx.main.scheduler.tasks.run_task_manager(*[])
2020-04-12 12:23:18,466 DEBUG    awx.main.scheduler Running Tower task manager.
2020-04-12 12:23:18,472 DEBUG    awx.main.scheduler Starting Scheduler
2020-04-12 12:23:28,468 DEBUG    awx.main.dispatch task ba9a6c3e-24b3-49e4-8cf1-62f90f315780 starting awx.main.tasks.awx_periodic_scheduler(*[])
2020-04-12 12:23:28,478 DEBUG    awx.main.tasks Starting periodic scheduler
2020-04-12 12:23:28,480 DEBUG    awx.main.tasks Last scheduler run was: 2020-04-12 12:22:58.567745+00:00
2020-04-12 12:23:38,483 DEBUG    awx.main.dispatch task 7f4ac140-7231-4c6e-901f-34be80529707 starting awx.main.scheduler.tasks.run_task_manager(*[])
2020-04-12 12:23:38,493 DEBUG    awx.main.scheduler Running Tower task manager.
2020-04-12 12:23:38,502 DEBUG    awx.main.scheduler Starting Scheduler
2020-04-12 12:23:58,522 DEBUG    awx.main.dispatch task 7ed5d956-ba67-4219-9509-1405713fa155 starting awx.main.tasks.cluster_node_heartbeat(*[])
2020-04-12 12:23:58,632 DEBUG    awx.main.tasks Cluster node heartbeat task.
2020-04-12 12:23:58,508 DEBUG    awx.main.dispatch task 7ca00dc2-ab9c-4c65-b505-f880afc47f65 starting awx.main.tasks.gather_analytics(*[])
2020-04-12 12:23:58,560 DEBUG    awx.main.dispatch task 0e539914-105c-462f-89c6-20f1a50b1ec8 starting awx.main.tasks.awx_periodic_scheduler(*[])
2020-04-12 12:23:58,693 DEBUG    awx.main.tasks Starting periodic scheduler
2020-04-12 12:23:58,696 DEBUG    awx.main.tasks Last scheduler run was: 2020-04-12 12:23:28.480007+00:00
2020-04-12 12:23:58,536 DEBUG    awx.main.dispatch task 5ec695f4-80f2-44a0-a18f-cdaa62215b10 starting awx.main.tasks.awx_k8s_reaper(*[])
2020-04-12 12:23:58,622 WARNING  awx.main.dispatch scaling up worker pid:159
2020-04-12 12:23:58,738 DEBUG    awx.main.dispatch task a643c365-145c-4bde-9536-d2f647d243f0 starting awx.main.scheduler.tasks.run_task_manager(*[])
2020-04-12 12:23:58,747 DEBUG    awx.main.scheduler Running Tower task manager.
2020-04-12 12:23:58,752 DEBUG    awx.main.scheduler Starting Scheduler
RESULT 2
OKREADY

Now we will need to install prerequisites for DellEMC Ansible module – PyU4V package. Follow below steps to install DellEMC Ansible module dependencies.

Connect to the container awx_task

[root@dw-test-1 installer]# docker exec -it awx_task bash

On the container prompt run below command to install PyU4V package

bash-4.4# pip3 install PyU4V==9.1.1.0
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting PyU4V==9.1.1.0
  Downloading https://files.pythonhosted.org/packages/38/83/34e7d4b823f84b74f6ac959b3cc5302882022f65c78e9f91593d531ebd1d/PyU4V-9.1.1.0-py3-none-any.whl (79kB)
    100% |████████████████████████████████| 81kB 2.4MB/s
Collecting urllib3 (from PyU4V==9.1.1.0)
  Downloading https://files.pythonhosted.org/packages/e8/74/6e4f91745020f967d09332bb2b8b9b10090957334692eb88ea4afe91b77f/urllib3-1.25.8-py2.py3-none-any.whl (125kB)
    100% |████████████████████████████████| 133kB 3.4MB/s
Collecting prettytable (from PyU4V==9.1.1.0)
  Downloading https://files.pythonhosted.org/packages/ef/30/4b0746848746ed5941f052479e7c23d2b56d174b82f4fd34a25e389831f5/prettytable-0.7.2.tar.bz2
Requirement already satisfied: six in /usr/lib/python3.6/site-packages (from PyU4V==9.1.1.0)
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from PyU4V==9.1.1.0)
Collecting requests (from PyU4V==9.1.1.0)
  Downloading https://files.pythonhosted.org/packages/1a/70/1935c770cb3be6e3a8b78ced23d7e0f3b187f5cbfab4749523ed65d7c9b1/requests-2.23.0-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 4.4MB/s
Collecting chardet<4,>=3.0.2 (from requests->PyU4V==9.1.1.0)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 3.8MB/s
Collecting certifi>=2017.4.17 (from requests->PyU4V==9.1.1.0)
  Downloading https://files.pythonhosted.org/packages/57/2b/26e37a4b034800c960a00c4e1b3d9ca5d7014e983e6e729e33ea2f36426c/certifi-2020.4.5.1-py2.py3-none-any.whl (157kB)
    100% |████████████████████████████████| 163kB 3.8MB/s
Requirement already satisfied: idna<3,>=2.5 in /usr/lib/python3.6/site-packages (from requests->PyU4V==9.1.1.0)
Installing collected packages: urllib3, prettytable, chardet, certifi, requests, PyU4V
  Running setup.py install for prettytable ... done
Successfully installed PyU4V-9.1.1.0 certifi-2020.4.5.1 chardet-3.0.4 prettytable-0.7.2 requests-2.23.0 urllib3-1.25.8

Once completed you can check installed version using

bash-4.4# pip3 list | grep PyU4V
PyU4V (9.1.1.0)

At this point you have AWX up and running and can be reached on http://localhost:80.

Tower is now running on the host at port 80.  The rest of the setup is handled by the web interface .  If you did this on the system you are using you can use http://localhost.

If everything went well then you can see login prompt similar to the below screenshot. Login credentials for AWX are as per inventory file.

undefined

This concludes Ansible Tower (AWX) installation process. In next posts we will discuss on configuring Ansible Tower / AWX.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s