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:
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:
- Cloud Inventory - Authentication towards our Cloud hosting our resources
- 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:
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
- Within Ansible Tower
- 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: HOSTS
- 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: Source Host File
- Select the Sourced from a Project from the SOURCE Dropdown
- Select the Project from the PROJECT Dropdown
- Select the Inventory File, most likely a file named: hosts form the INVENTORY FILE DROPDOWN
- Check OVERWRITE Checkbox from the UPDATE OPTIONS
- Check UPDATE ON LAUNCH Checkbox from the UPDATE OPTIONS
- Click the Green SAVE Button
- Click the Refresh Button from the SOURCES Grid
- 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 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:
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!