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:
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
- Within Ansible Tower
- Under Resources -> Projects on the left hand navigation
- Click Projects Link on the left hand side of the browser
- Locate the project EDB-ANSIBLE-GALAXY
- Click the Get the latest SCM Revision Button under the Name Column
- Wait for the Green Cloud to be solid next to the EDB-ANSIBLE-GALAXY Project
- A directory located in: /var/lib/awx/projects with the _xx__project_name will be available
Download locally the EDB-CLOUD-INVENTORY
- Within Ansible Tower
- Under Resources -> Projects on the left hand navigation
- Click Projects Link on the left hand side of the browser
- Locate the project EDB-CLOUD-INVENTORY Project
- Click the Get the latest SCM Revision Button under the Name Column
- Wait for the Green Cloud to be solid next to the EDB-CLOUD-INVENTORY Project
- A directory located in: /var/lib/awx/projects with the _xx__project_name will be available
Prepare a local manual Ansible Tower Ansible Project
- Open a Terminal Window
- 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
- Within Ansible Tower
- Under Resources -> Projects on the left hand navigation
- Click Projects on the left hand navigation
- Click the Green Plus Sign on the right hand side of the browser
- Enter the name of the project, for example: EDB-Ansible
- Select Manual from the SCM TYPE Dropdown
- Select edb-ansible from the PLAYBOOK DIRECTORY Dropdown
- Click the Green SAVE Button
The project should look similar to the results below:
Create the Template
- Within Ansible Tower
- Under Resources -> Templates on the left hand navigation
- Click the Green Plus Sign on the right hand side of the browser
- Click Job Template
- Enter the name, for example: EDB-ANSIBLE-TEMPLATE
- Select Run from the JOB TYPE Dropdown
- Select HOSTS from the INVENTORY Dropdown
- Select EDB-ANSIBLE from the PROJECT Dropdown
- Select the playbook.yml from the PLAYBOOK Dropdown *Keep in mind the machine and the Cloud credentials filter when selecting the credentials*
- Select the <your_cloud_credentials>from the PLAYBOOK Checkbox
- Select the <your_cloud_private_key_credentials>from the CREDENTIALS Checkbox
- 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"
- Check ENABLE PRIVILEGE ESCALATION from the OPTIONS Checkbox
- Click the Green SAVE Button
The completed template should like similar to the screenshot below:
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:
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!