Ansible Tower/Automation Controller

Khemnath chauhan
6 min readAug 10, 2024

--

The main difference between Ansible Tower and Ansible Automation Platform is that Ansible Tower is an older version of the software which has now been replaced by Ansible Automation Controller which in turn is part of the Ansible Automation Platform.
Ansible automation controller is the web-based UI interface for Red Hat Ansible Automation Platform.

Using the web-UI interface, we can create an Inventory to manage our servers, import our playbooks through the Projects, add Job Templates to run the playbooks and finally, create a Workflow linking a few of those playbooks through success or failure conditions.

The mode of operation of controller has evolved and now uses container technology to run the jobs. This replaces the notion of the Python virtual environment known previously in Tower. Containers and their images, used for the execution of each job are known are known as execution environment.

Below is new dashboard of Ansible Controller:

You will find the following buttons. If you click any of them it will take you to the corresponding section.

  • Hosts
  • Failed hosts
  • Inventories
  • Inventory sync fail
  • Projects
  • Projects sync fail.

INVENTORY:

An inventory is a collection of hosts against which jobs (ex. playbooks) may be launched, the same as an Ansible inventory file, it indicates which nodes will be managed by the control machine, in this case the automation controller.
Inventories may be divided into groups and these groups contain the actual hosts. The hosts may be sourced manually or dynamically and can be referenced by their IP addresses or their hostnames.
In automation controller you will be able to run multiple playbooks against these inventories without recreating them.

Creation of Inventory:

  1. On the side navigation bar, under the Resources section, click on Inventories
  2. Click on the blue Add button
  3. Select Add inventory from the dropdown
  4. Name it Dev-hosts . Leave all the other fields as they are.
  5. Click Save
Ansible Controller
Ansible Controller(Inventory)
Ansible Controller (Inventory)

ADD HOSTS TO — DEV-HOSTS INVENTORY:

  1. On the tab bar, click on Hosts
  2. Click on the blue Add button.
  3. In the Name text box enter node01 . Leave all the other fields as they are.
  4. Click Save
  5. Click on the Hosts menu in the sidebar or use the breadcrumb Back to hosts
  6. Repeat the above steps to create a new host, named node02.

CREATE GROUP IN DEV-HOSTS :

  1. On the sidebar, go to Inventories and click on the Dev-hosts
  2. On the tab bar of Dev-hosts, click on Groups
  3. Click on the Add button to create a new group.
  4. Create a new group named web (NOTE: you don't need to input the [ ] like you would in an inventory file).
  5. Click Save when you are finished.
Ansible Controller (Groups)

ADD node01 and node02 to web Group:Click on the Hosts tab on the top menu of the web group

  1. Click Add existing host. A pop up will appear.
  2. Select both node1 and node2 then click Save.
  3. Verify node1 and node2 are now added to the web group.

PROJECTS:

Projects are logical groups of Ansible playbooks in automation controller. These playbooks usually reside in a source code version control system like Git (and platforms as Github or Gitlab). With Projects we can reference a repository or directory with one or several playbooks, that we will later use.
We use Projects to “import” our playbooks into automation controller. These playbooks might be in a source control management (SCM) like Git (in GitHub or Gitlab for ex.) or locally. Automation controller doesn’t allow us to create or edit playbooks through the web-UI, we can only “import” them into Projects which we later run through the Job Templates feature

CREATE PROJECT:

  1. Click the Projects link in the Resources section of the sidebar
  2. Click the Add button
  3. Name the Project as Apache playbooks
  4. For the Source Control Type dropdown, select Git, this will enable new fields below.
  5. For the Source Control URL field — copy the scm repo URL:
Dashboard
Create Project

Check the New Project is Sync:

  1. Click the Projects link in the Resources section of the sidebar
  2. Verify that the Status for our Apache playbooks project is green and reads Successful
  3. Click the Successful and review the output of the sync.
Click-Successful

CREDENTIALS:

Credentials are utilized by automation controller for authentication when launching jobs against machines, synchronizing with inventory sources, and importing project content from a version control system.

Credentials are imported and stored encrypted within automation controller, and are not retrievable in plain text on the command line by any user. You can grant users and teams the ability to use these credentials, without actually exposing the credential to the user itself.
There are multiple types of credential types, ranging from tokens, to user/passwords or public keys. In total, there are over 20 supported types and even the option to create Custom ones. We will explore the Machine credential type today, which we will use to connect to the servers in our inventory through SSH.

Credentials
Credentials Details

- Click the Access tab to see who has access to use this credential. These are the automation controller users.
- Click the Job Templates tab to see what Jobs are currently using this credential.

Exploring the Machine type Credentials:

  1. Go back to the Details tab of the lab-credentials
  2. Click the Edit button
  3. Look at the different fields available.
  4. Notice how the SSH Private Key field only allows us to Reset. As mentioned before, the key is encrypted and not retrievable.
  5. To exit, click the Cancel button to avoid accidental modifications.

JOB TEMPLATE:

In automation controller a job template is a definition and set of parameters for running an Ansible job, which is usually known as a playbook. Job Templates are useful to execute the same job many times. Job templates also encourage the reuse of Ansible content and collaboration between teams.

To create a Job Template you need to have a Project from which to source our Playbooks. We created our project in the previous challenge. Also note that although a Project might contain multiple Playbooks, a Job Template can only run one of those playbooks.

In automation controller when we want to run multiple playbooks we need to use a Job Template Workflow.

Create Job Template:

  1. Click the Templates link in the Resources section of the sidebar
  2. Click the Add dropdown button and select Add job template
  3. Name the Job Template as Install Apache
  4. For the Job Type field, leave the default: Run
  5. For the Inventory field, touch the magnifying glass and select Lab-Inventory
  6. For the Project field, touch the magnifying glass and select Apache playbooks
  7. For the Playbook dropdown field, you will notice that it’s auto populated with all the playbooks available in the Project repository we selected. Choose the apache.yml.
  8. For the Credentials field, touch the magnifying glass and select lab-credentials
  9. Leave all the other fields the same and click Save
Ansible Controller- Template
Create Template

--

--