Ansible Tower: Installation, End to End Automation Demo..!!

Shrishti Kapoor
7 min readJan 16, 2023

About Ansible

Ansible Tower is the enterprise version of Ansible. It allows sysadmins to deploy all of the benefits of Ansible at scale. And, like Ansible, it integrates with a broad base of your existing technology infrastructure: networking, security, application deployment, storage, software development lifecycle processes, etc.

Features of Ansible Tower

  1. Graphical user interface (GUI) dashboard
  2. Role-based access control
  3. Job scheduling
  4. Multi-playbook workflows
  5. External logging integrations
  6. Real-time job status updates
  7. RESTful API

Setup and Installation

Installation can be done in local Virtual Machines or by creating instance in cloud. For this setup I used AWS.

Requirements -:

RedHat Developer Account :

First, you need one RedHat Developer Account which is absolutely free of cost. Go to https://developers.redhat.com/ & create one account. In upcoming steps, you will come to know the reason.

Step-1) To launch Instance, I used Ec2 service of AWS.

Required- Minimum RAM-4Gb and Redhat8.

Choose RedHat Enterprise Linux8.

Choose Instance Type as t2.medium

Step-2) Now Login into the VM.

To get ansible-tower setup bundle follow this link- https://releases.ansible.com/ansible-tower/setup-bundle/ and then copy ansible-tower-setup-bundle-3.8.6–2.tar.gz

Now use tar -xvzf ansible-tower-setup-bundle-3.8.6.2.tar.gz to unzip.

Give password in admin_password and pg_password.

Before running that setup.sh file check ram by free -m

Since this is not sufficient so while running setup.sh some error related to preflight checks will be there, to avoid that error follow these steps:

cd roles/preflight/defaults/main.yml

Edit main.yml, change required_ram as 2048.

Now run setup.sh file to configure entire setup of ansible tower by using — ./setup.sh

Ansible setup done successfully..!!

Step-3) Now Copy public IP of Instance and Open in new tab and click on advanced option.

After clicking on advanced, now give the username and password given in the configuration file.

After login now we need the id and password from which developer account is made, Login using that details and get subscription.

Choose RedHat Developer Subscription for individulas.

Agree to License agreement and Click on Submit.

After Submitting the Ansible Tower Dashboard will be there. Now you can perform any tasks related to Ansible Tower.

End to End Automation Demo.

End to End Automation

Step-1) For this Setup We require 2 instances with following details as shown in the given screenshots.

Create a new key pair.

Here Ansible Tower instance is running ansible tower or can be a controller node and node1 and node2 are the managed nodes.

Step-2) Now Go to Ansible Tower Dashboard. I created 2 inventories and added hosts in that inventory.

For beginner's The Ansible inventory here is a file that defines the hosts and groups of hosts upon which commands, modules, and tasks in a playbook operate.

Now Go to Inventories → +(click on this green icon) → Inventory

Now give the inventory name and add Hosts. In hosts give public IP of node1.

Similarly creating another inventory and give the inventory name with adding Hosts. In hosts give public IP of node2

Now there are 2 inventories named- SK-Prod-inventory and SK-Dev-inventory.

Step-3) Now create credentials as given in screenshot. In ssh private key give the private key which was created during instance creation.

Give privelege escalation method as sudo and privelege escalation username as root.

Step-4) Now we need a script so for that I used Github, I created a repository and used gitbash to push the code. Before pushing code, clone the repository by using git clone Repo_url.

Now creating yml file as shown below.

After creating file use following commands :

git add web.yml

git commit -m “firstchange done”

git push

Step-5) Now in Ansible Tower dashboard Go to projects → new project and create project using following details and save.

Step-6) Now Open Github go to settings →developer settings → Tokens-Personal access token.

Create token by giving details.

After creating token, copy the entire token and Go to Ansible Tower dashboard and create credentials as shown in screenshot.

Paste the token in the token column and save.

Step-7) Now go to templates->Job Template.

Add details as shown below in screenshots.

Copy the webhook URL.

Step-8) Now go to github Settings of repository →Add Webhooks and follow below steps. In payload URL paste webhook url from template in ansible tower portal and follow the steps shown in screenshot.

Paste the key also, copied from ansible tower template’s and follow below steps to add webhook.

Now green tick means that ansible tower is now integrated with github.

Step-9) Now edit the file and as soon as we push everything is done automatically we need to run job.

Now as soon as we run job everything will run automatically and the updated things will be there.

I hope this blog is helpful to you...!!

--

--

Shrishti Kapoor

Spread Knowledge because it’s all about Right Education..!!