Overview
In this article, we will walk you through the steps required to select an Ansible Tower playbook dynamically using the SovLabs Template Engine.
Considerations
- Have licensed the Ansible Tower
- Have already configured the SovLabs Ansible Tower Module
Procedure
Adding template engine text to your Ansible Tower Profile
- From the Catalog (1), search for Ansible (2) and then click on Request (3) under Add Ansible Tower Profile - SovLabs Modules
- Provide a Configuration Label for your Ansible Tower profile
- Select your Ansible Tower Endpoint (If you have not configured this, please see Additional Information for links to our SovLabs Documentation)
- Optionally select to Filter Projects by Team and Filter Job Templates by Project
- Remove the check from the Get Job templates from List?
- Once removed you will notice that the list of Job Templates that was once there will be removed and you will be left with a text field. There is a default item which is all job templates. Remove this text by clicking the red x.
- Based on your requirements and how you have configured your Job Templates in Ansible will depend on what you enter next.
For example; All of my installation templates begin with InstApp- . So i could enter InstApp-{{Ansible-AppSelection}} and make the second portion dynamic.
If you do not have a standard for the Job Templates, then you may choose to enter a complete template engine text such as {{AnsibleTowerJob}}
Click on the green plus to add the Dynamic Job Template - Repeat step 5 → 7 for the Get Deprovision Job Templates from
Note: I configured any deprovision Job templates with RemApp- . This allows me to have a single input defined and it has a matching installation and removal job in ansible. - Optionally place a check in Ignore Job Run Errors?
- Select the Machine Credentials from the list OR type in the Machine Credentials (I will select an existing set)
- Select the inventory to use OR type in the inventory name (I will select an existing inventory)
- Optionally enter any extra variables you require
- Click on Submit
- You have now created a dynamic Ansible Tower Profile
Create a Property definition
Depending on how you will be capturing the details for Ansible tower will depend on if you need this specific step. This will allow you to add a drop down to your blue print and pass that value to Ansible Tower
- Under Administration (1) click on Property Dictionary (2) then Property Definitions (3)
- Click on New
- Enter the name (1) of the property, in my example I am using Ansible_AppSelection as the name, Enter a label (2) or leave the default and next to data type, select String (3)
- Next to display as, select Dropdown and leave the Values as Static List
- In the static list, enter the name of the item ie; application and the value being the name of the ansible playbook to run.
NOTE: I have a selection called N/A with a value of SKIP. This playbook does not exist so it will not execute any installation and skip the Ansible Tower job run. This is optional - Once completed, click on OK
Adding the property definition to your blueprint
- On your blueprint, go to properties (1), Property Groups (2) and click on Add (3)
- In the pop out window, locate the Ansible Tower Profile you created earlier, it will start SovLabs-Ansible-TowerProfile-<Tenant>_<AnsibleTowerProfileName>, then click on OK
- On your blueprint, click on Custom Properties and click on New
- In the Name field, enter the name of the property definition you created earlier, in my example it was called Ansible_AppSelection
- Under show in request, place a check in the box
- Click on OK
- Click on Finish
Deploying your blueprint
- On your blueprint you will see a selection for the property definition you created, mine is labelled "Select application to install".
- If I select Postgress SQL it will trigger the Postgresql ansible playbook. If I had of select N/A, it will skip as the playbook does not exist.
- Postgresql install
- N/A selected
- Postgresql install
Additional information
SovLabs Ansible Tower : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/modules/configuration-mgmt/ansible-tower/
Template Engine : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/framework/sovlabs-template-engine/basics/intro/
0 Comments