Workflow Templates link multiple Job Templates together. These Job Templates don’t even have to share inventory, Playbooks or even permissions. Furthermore, the links can be conditional. For example:

  • If job template A succeeds, job template B automatically executes afterwards
  • But in case of failure, job template C will be run.

This actually allows you to have different teams, make their own Job Templates or even their own Projects and still link them together all to the work into as one coherent Workflow.

This approach builds on an example from an earlier blog post I shared – Working with AWX Tower.  You can also use that post as a refresher for how to create Job Templates and Surveys.

Three new job templates are going to be created:

  • Export Policy creation
  • Export Policy Rule creation
  • Volume creation, but this time without any variables or surveys.

NOTE: If you try to use a Job Template in a Workflow Template that has a survey, all the questions must have their answers  entered in the Workflow builder before you can use the Template.

The first step in this example is to create three Job Templates.  These Job Templates will be the building blocks for a Workflow Template.  These Job Template examples are straight forward.  If you need help you can refer back to my earlier post <provide link> on how to create a Job Template.  Use this information when creating the Job Templates

NAME: Export Policy no survey
JOB TYPE: Run
INVENTORY: Demo Inventory
PROJECT: NetApp Tasks
PLAYBOOK: policy.yml
CREDENTIAL: NetApp Admin

NAME: Policy Rule no survey
JOB TYPE: Run
INVENTORY: Demo Inventory
PROJECT: NetApp Tasks
PLAYBOOK: rule.yml
CREDENTIAL: NetApp Admin

NAME: Volume Create no survey
JOB TYPE: Run
INVENTORY: Demo Inventory
PROJECT: NetApp Tasks
PLAYBOOK: volume.yml
CREDENTIAL: NetApp Admin

Default variables can be added to workflows to override any variables set in the playbooks or to allow setting variables.  These are entered in the “EXTRA VARIABLES” section in the same way that you add them to a variables file.

Since this Volume Create no survey will always be used for NFS,   in this example, add a variable for the export_policy before you save the Job Template.

1 ---
2 export_policy: “{{ volname }}”

Once this is done the actual Workflow Template can now be created. Workflows are configured in the Templates view,  You might have noticed you can choose between a Job Template  view or a Workflow Template view when adding a template.    For this example:Go to the Templates view and click the green plus button . This time choose Workflow Template

NAME: NFS Export
ORGANIZATION: Default

  • Click SAVE

After saving the template, the Workflow Visualizer opens to allow you to build a workflow. If needed, the Workflow Visualizer can be openned again later  from the template details page.

Click on the START button and, a new node opens. On the right you can assign an action to the node, you can choose between JOBSPROJECT SYNC and INVENTORY SYNC.

For this example, I am linking Jobs together, so select the Export Policy no survey job and click SELECT.

The node gets annotated with the name of the job. Hover the mouse pointer over the node, you’ll see a red x, a green + and a blue chain-symbol appear.

Click the green + sign
Choose Policy Rule no survey as the next Job (you might have to switch to the next page)
Leave Type set to On Success
Click SELECT

Click the green + sign  on the Policy Rule no survey task
Choose Volume Create no survey as the next Job (you might have to switch to the next page)
Leave Type set to On Success
Click SELECT
Click SAVE in the WORKFLOW VISUALIZER view
Click SAVE in the Workflow Template view

Tip
The Workflow Visualizer has options for setting up more advanced workflows, please refer to the documentation

We are also going to add some extra variables to this Workflow so that its settings are consistent and so that you can see how this can be done.  So that this Workflow always creates the same NFS rules the following needs to be added to Extra Variables.

1 ---
2 ro_rule: sys
3 rw_rule: sys
4 su_rule: sys

Click SAVE

The final step is to create a survey for the NFS Export Template Workflow.  Refer back to the earlier linked post to remember how to create a survey.  You need the following to be defined.

  • hostname
  • vserver
  • aggrname
  • volname
  • client_match
  • size

Your workflow is ready to go, so the next step is to launch it.

Click the blue LAUNCH button directly or go to the Templates view and launch the NFS Export workflow by clicking the rocket icon.

Note how the workflow run is shown in the job view. In contrast to a normal Job Template job execution, this time there is no playbook output on the right. Instead you will see a visual representation of the different workflow steps. If you want to look at the actual playbooks behind that template, click DETAILS in each step. If you want to get back from the details view to the corresponding workflow, click the back button in your browser.

Now you have all the necessary steps to make your own Workflow Templates and are ready to start using the power of Tower.

As always, any questions can be asked in our Slack workspace in the #configurationmgmt channel.

Don’t have our Slack yet?  Get an invite at netapp.io/slack.

David Blackwell on Linkedin
David Blackwell
Technical Marketing Engineer at NetApp
David is a twenty year IT veteran who has been an admin for just about every aspect of a DataCenter at one time or another. When not working, or tinkering with new software at home, David spends most of his free with his four year old son and his lovely wife.

Pin It on Pinterest