Ansible Tower - Dynamically select your Ansible playbooks using template engine


In this article, we will walk you through the steps required to select an Ansible Tower playbook dynamically using the SovLabs Template Engine.


  • Have licensed the Ansible Tower
  • Have already configured the SovLabs Ansible Tower Module


Adding template engine text to your Ansible Tower Profile

  1. From the Catalog (1), search for Ansible (2) and then click on Request (3) under Add Ansible Tower Profile - SovLabs Modules

  2. Provide a Configuration Label for your Ansible Tower profile

  3. Select your Ansible Tower Endpoint (If you have not configured this, please see Additional Information for links to our SovLabs Documentation)

  4. Optionally select to Filter Projects by Team and Filter Job Templates by Project

  5. Remove the check from the Get Job templates from List?

  6. 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.

  7. 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

  8. 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.

  9. Optionally place a check in Ignore Job Run Errors?

  10. Select the Machine Credentials from the list OR type in the Machine Credentials (I will select an existing set)

  11. Select the inventory to use OR type in the inventory name (I will select an existing inventory)

  12. Optionally enter any extra variables you require

  13. Click on Submit

  14. 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

  1. Under Administration (1) click on Property Dictionary (2) then Property Definitions (3)

  2. Click on New

  3. 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)

  4. Next to display as, select Dropdown and leave the Values as Static List

  5. 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

  6. Once completed, click on OK

Adding the property definition to your blueprint

  1. On your blueprint, go to properties (1), Property Groups (2) and click on Add (3)

  2. 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

  3. On your blueprint, click on Custom Properties and click on New

  4. In the Name field, enter the name of the property definition you created earlier, in my example it was called Ansible_AppSelection

  5. Under show in request, place a check in the box

  6. Click on OK

  7. Click on Finish

Deploying your blueprint

  1. On your blueprint you will see a selection for the property definition you created, mine is labelled "Select application to install".
  2. 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.
    1. Postgresql install

    2. N/A selected

Additional information

SovLabs Ansible Tower :
Template Engine :

Have more questions? Submit a request


Please sign in to leave a comment.