Get More Out of edb-ansible Scripts: Creating Ansible Tower Projects

March 11, 2021

As part of our never-ending quest at EDB to innovate and integrate with other products, we continue our series about integrating EDB “edb-ansible” scripts with Ansible Tower with this second blog post. In our previous post, Ansible Tower and Postgres Reference Architectures, we looked at how Ansible differs from Ansible Tower, provided a brief overview of how Ansible Tower can be utilized in conjunction with “edb-ansible” scripts, and described the components of 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 Project?

An Ansible Tower Project is a logical collection of Ansible Playbooks. Playbooks can be managed within an Ansible Tower Project:

  1. Manually within a directory in the Tower Server - /var/lib/awx/projects. We will perform this process in a project prior to creating the Ansible Tower Template.
  2. Importing from a Source Control Management System such as: Git, Subversion or Mercurial. Which is what we will be accomplishing in this blog.


With an understanding of what an Ansible Tower Project is, we will need to create two projects:

  • Project to download the hosts inventory file
  • Project to download the edb_devops.edb_postgres Ansible Galaxy Collection

 

Requirements for the project to download the hosts inventory file

Create a Project that connects to the github repository that contains your host file in a format such as:

all:
  children:
    pemserver:
      hosts:
        pemserver1:
          ansible_host: xxx.xxx.xxx.xxx
          private_ip: xxx.xxx.xxx.xxx
    primary:
      hosts:
        primary1:
          ansible_host: xxx.xxx.xxx.xxx
          private_ip: xxx.xxx.xxx.xxx
          pem_agent: true
          pem_server_private_ip: xxx.xxx.xxx.xxx
    standby:
      hosts:
        standby1:
          ansible_host: xxx.xxx.xxx.xxx
          private_ip: xxx.xxx.xxx.xxx
          upstream_node_private_ip: xxx.xxx.xxx.xxx
          replication_type: synchronous
          pem_agent: true
          pem_server_private_ip: xxx.xxx.xxx.xxx
        standby2:
          ansible_host: xxx.xxx.xxx.xxx
          private_ip: xxx.xxx.xxx.xxx
          upstream_node_private_ip: xxx.xxx.xxx.xxx
          replication_type: asynchronous
          pem_agent: true
          pem_server_private_ip: xxx.xxx.xxx.xxx


The repository should also contain:

  • A folder named: collections
  • A file named: requirements.yml with the content:
collections:
  - name: edb_devops.edb_postgres

 

Create the hosts inventory file project

  1. Click Projects on the left hand navigation
  2. Click the Green Plus Sign on the right hand side of the browser
  3. Enter the name of the project, for example: EDB-CLOUD-Inventory
  4. Select Git from the SCM TYPE Dropdown
  5. Type in the SCM URL TextBox: http://<your_repository>
  6. Check Clean CheckBox from the SCM UPDATE OPTIONS
  7. Click the Green SAVE Button

The project should like similar to the screenshot below:

 

Create the project to download the edb_devops.edb_postgres Ansible Galaxy Collection

  1. Click Projects on the left hand navigation
  2. Click the Green Plus Sign on the right hand side of the browser
  3. Enter the name of the project, for example: EDB-ANSIBLE-GALAXY
  4. Select Git from the SCM TYPE Dropdown
  5. Type in the SCM URL TextBox: https://github.com/EnterpriseDB/edb-ansible-tower
  6. Check Clean CheckBox from the SCM UPDATE OPTIONS
  7. Click the Green SAVE Button

The project should look similar to the results below:

 

Summary

Creating projects in Ansible Tower is not difficult, but you do have to plan and take into account their purpose at the moment of their creation, and how these projects will interact with the other components: Inventories, Credentials and Templates. The following blog topics I'll cover will build towards the final step, which will be creating a manual local Project and a Template for its execution.

Stay tuned for the upcoming blog post, Configuring Credentials for “edb-ansible” Scripts on Ansible Tower!

 

Share this

More Blogs

Solving Your DBA Talent Gap: Upskill vs. Outsource

DBAs provide vital management and monitoring for your organization’s architecture, ensuring that you don’t fall prey to avoidable outages, lose access to mission-critical applications or data during an upgrade or...
March 14, 2023