Skip to content
Announcing BigAnimal: Fully managed PostgreSQL in the Cloud
Postgres Build 2021: 30 Nov to 1 Dec
Contact usDocsPlans

How to Create a Template for edb-ansible Scripts in Ansible Tower

Doug Ortiz6/21/2021
Getting started

Concluding our series about integrating EDB “edb-ansible” scripts with Ansible Tower, our previous post was about: Creating “Inventories” for “edb-ansible” Scripts in Ansible Tower. In the last post of the series, we will be looking at: How to Create a “Template” 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 Template?

An Ansible Tower Template is a logical unification of:

  • Credential
  • Project
  • Inventory

There are two types of Ansible Tower Templates:

  • Job Template - The conjunction of template, project and inventory that can be utilized. A template(s) can be utilized in a Workflow Template
  • Workflow Template - For the creation of sequences from a combination of templates, projects and inventories

For our purposes in the blog the Job Template is what we are interested in.

 

Create a Local Manual in an Ansible Tower Project

A local manual project is an Ansible Tower Project that is created via the Terminal. The reason to create a project of this type is because multiple downloaded resources exist in separate downloaded projects. Since we cannot merge these downloaded projects, manual intervention is required to merge the content from multiple downloaded projects into a single project folder. The last step is to create the project in the Ansible Tower Projects Interface so that it is recognized, ready and mapped to the manually created project folder. 

The location for the content of downloaded projects is: /var/lib/awx/projects

Download locally the edb_devops.edb_postgres Ansible Galaxy Collection

  1. Within Ansible Tower
  2. Under Resources -> Projects on the left hand navigation
  3. Click Projects Link on the left hand side of the browser
  4. Locate the project EDB-ANSIBLE-GALAXY
  5. Click the Get the latest SCM Revision Button under the Name Column
  6. Wait for the Green Cloud to be solid next to the EDB-ANSIBLE-GALAXY Project
  7. A directory located in: /var/lib/awx/projects with the _xx__project_name will be available
     

Download locally the EDB-CLOUD-INVENTORY

  1. Within Ansible Tower
  2. Under Resources -> Projects on the left hand navigation
  3. Click Projects Link on the left hand side of the browser
  4. Locate the project EDB-CLOUD-INVENTORY Project
  5. Click the Get the latest SCM Revision Button under the Name Column
  6. Wait for the Green Cloud to be solid next to the EDB-CLOUD-INVENTORY Project
  7. A directory located in: /var/lib/awx/projects with the _xx__project_name will be available
     

Prepare a local manual Ansible Tower Ansible Project

  1. Open a Terminal Window
  2. Type
sudo su
cd /var/lib/awx/projects
mkdir edb-ansible
cd edb-ansible
cp -r ../\_**xx__edb_ansible_galaxy**/collections/ .
cp -r ../\_**xx__edb_ansible_galaxy**/plugins/ .
cp -r ../\_**xx__edb_ansible_galaxy**/playbook.yml .

 

Create the Ansible Tower edb-ansible Project

  1. Within Ansible Tower
  2. Under Resources -> Projects on the left hand navigation
  3. Click Projects on the left hand navigation
  4. Click the Green Plus Sign on the right hand side of the browser
  5. Enter the name of the project, for example: EDB-Ansible
  6. Select Manual from the SCM TYPE Dropdown
  7. Select edb-ansible from the PLAYBOOK DIRECTORY Dropdown
  8. Click the Green SAVE Button

The project should look similar to the results below:

Ansible Tower

 

Create the Template

  1. Within Ansible Tower
  2. Under Resources -> Templates on the left hand navigation
  3. Click the Green Plus Sign on the right hand side of the browser
  4. Click Job Template
  5. Enter the name, for example: EDB-ANSIBLE-TEMPLATE
  6. Select Run from the JOB TYPE Dropdown
  7. Select HOSTS from the INVENTORY Dropdown
  8. Select EDB-ANSIBLE from the PROJECT Dropdown
  9. Select the playbook.yml from the PLAYBOOK Dropdown *Keep in mind the machine and the Cloud credentials filter when selecting the credentials*
  10. Select the <your_cloud_credentials>from the PLAYBOOK Checkbox
  11. Select the <your_cloud_private_key_credentials>from the CREDENTIALS Checkbox
  12. The EXTRA VARIABLES Textbox should have the parameters for the playbook as listed below:
---
pg_version: 12
pg_type: "EPAS"
yum_username: "yum_user"
yum_password: "yum_password"
  1. Check ENABLE PRIVILEGE ESCALATION from the OPTIONS Checkbox
  2. Click the Green SAVE Button

The completed template should like similar to the screenshot below:

Ansible Tower

Now for the moment we have been waiting for:

Click the Launch Button.

Time to get a cup of coffee and depending on your hardware, between 15-30 minutes to drink it.

A successful execution of the template should look similar to the screenshot below:

Ansible Tower

 

Conclusion

In this blog series, we have taken a look at how to integrate EDB “edb-ansible” Scripts with Ansible Tower from start to finish. In the process, we have learned about:

  • Ansible Tower
  • EDB Reference Architectures
  • Projects
  • Credentials
  • Inventories
  • Local Manual Projects
  • Templates

We gained an understanding about how Ansible Tower components relate to each other and, most importantly, their relationships between them. Lastly, we executed a Template that configured EDB PostgreSQL Advanced Server on our Cloud Virtual Machines.

Hope to see you in future blog posts!

 

Doug Ortiz is a Postgres DevOps Engineer at EDB. Doug's skills encompass multiple platforms such as: AWS, Azure, GCP, Big Data, Data Analytics, DevOps, Linux, Kubernetes, Docker, Terraform, Ansible, Python, Scala, GraphQL, .Net, SharePoint, Office, Neo4J, MySQL, PostgreSQL and SQL Server.  He posses ...