Get More Out of edb-ansible Scripts: Creating “Inventories” in Ansible Tower

May 04, 2021

Continuing our series about integrating EDB “edb-ansible” scripts with Ansible Tower v3.8.1, our previous post was about: Creating “Credentials” for “edb-ansible” Scripts in Ansible Tower. In this fourth post of the series we will be looking at: Creating “Inventories” for “edb-ansible” Scripts in Ansible Tower.

In this blog post, we will be covering the greyed out areas in the diagram below:

Ansible Tower
Based on Red Hat Ansible User guide
 

What is an Ansible Tower Inventory?

An Ansible Tower Inventory is a logical collection of hosts on which the playbooks will be executed upon, there are two types of inventories:

  • Static - Hosts and their details are entered manually
  • Dynamic - Hosts are scaffolded and entered automatically

We will be creating two inventories in total:

  1. Cloud Inventory - Authentication towards our Cloud hosting our resources
  2. Hosts Inventory - Utilized to ssh into the Instances within our Cloud
     

Create the Cloud Inventory

Under Resources -> Inventories on the left hand navigation
Click the Green Plus Sign on the right hand side of the browser
Click Inventories
Enter the name, for example: GCloud - Inventory
Click the Green SAVE Button
Click the Sources Button on the top right
Click the Green Plus Sign on the right hand side of the browser
Enter the name, for example: GCloud - VMs
Select the CLOUD SOURCE from the SOURCE Dropdown
Click the Green SAVE Button
**Scroll down**
Locate the cloud - VMs recently created in the SOURCES Grid
Click the cloud - VMs project Start Sync Button on the right hand side under ACTIONS
Click the HOST BUTTON on the top right next to the Source Button
Wait for the Green Cloud to be solid
Verify that the List of Hosts matches the Cloud Virtual Machines in which EPAS/Postgres playbook will be executed upon by Clicking the HOST Button on the top of the grid

The completed inventory should like similar to the screenshot below:

Ansible Tower

Create the Host Inventory

Create a GitHub Repository in which you can upload/create a HOSTS file that contains the inventory to be utilized

The HOSTS file should look similar to the content listed below:
 

---
all:
  children:
    pemserver:
      hosts:
        pemserver1:
          ansible_host: 35.235.76.97
          private_ip: 10.168.0.3
    barmanserver:
      hosts:
        barmanserver1:
          ansible_host: 35.236.126.142
          private_ip: 10.168.0.2
    primary:
      hosts:
        primary1:
          ansible_host: 34.94.203.166
          private_ip: 10.168.0.4
          barman: true
          barman_server_private_ip: 10.168.0.2
          barman_backup_method: postgres
          pem_agent: true
          pem_server_private_ip: 10.168.0.3
    standby:
      hosts:
        standby1:
          ansible_host: 34.94.64.181
          private_ip: 10.168.0.5
          barman: true
          barman_server_private_ip: 10.168.0.2
          barman_backup_method: postgres
          replication_type: synchronous
          upstream_node_private_ip: 10.168.0.4
          pem_agent: true
          pem_server_private_ip: 10.168.0.3
        standby2:
          ansible_host: 34.94.164.251
          private_ip: 10.168.0.6
          barman: true
          barman_server_private_ip: 10.168.0.2
          barman_backup_method: postgres
          replication_type: asynchronous
          upstream_node_private_ip: 10.168.0.4
          pem_agent: true
          pem_server_private_ip: 10.168.0.3
  1. Within Ansible Tower
  2. Under Resources -> Inventories on the left hand navigation
  3. Click the Green Plus Sign on the right hand side of the browser
  4. Click Inventories
  5. Enter the name, for example: HOSTS
  6. Click the Green SAVE Button
  7. Click the Sources Button on the top right
  8. Click the Green Plus Sign on the right hand side of the browser
  9. Enter the name, for example: Source Host File
  10. Select the Sourced from a Project from the SOURCE Dropdown
  11. Select the Project from the PROJECT Dropdown
  12. Select the Inventory File, most likely a file named: hosts form the INVENTORY FILE DROPDOWN
  13. Check OVERWRITE Checkbox from the UPDATE OPTIONS
  14. Check UPDATE ON LAUNCH Checkbox from the UPDATE OPTIONS
  15. Click the Green SAVE Button
  16. Click the Refresh Button from the SOURCES Grid
  17. Click the HOST BUTTON on the top right next to the Source Button
  18. Wait for the Green Cloud to be solid
  19. Verify that the List of Hosts matches the Host List content of the file in the GitHub Repo utilized for the hosts file

The completed host inventory should like similar to the screenshot below:

Ansible Tower


Summary

By now, we are starting to get a glimpse of how the Ansible Tower components interact and depend upon another. One pulled an inventory file from a GitHub repository and the other from the cloud. In the next blog posting we will get to see the interaction of all the components together forming a custom manual local Project and a Template for its execution.

Keep an eye out for the next blog, Configuring Template for “edb-ansible” Scripts on Ansible Tower!
 

Share this

Relevant Blogs

Solving Your DBA Talent Gap: Upskill vs. Outsource

For businesses looking to leverage the full potential of Postgres database, there are few roles as important as database administrators (DBAs).  DBAs provide vital management and monitoring for your organization’s...
March 14, 2023

More Blogs