A workflow job template links together a sequence of disparate job templates that accomplishes the task of tracking the full set of jobs that were part of the release process as a single unit.
This menu opens a list of the workflow and job templates that are currently available. The templates list may be sorted and searched by Name or Description. The Job Templates tab also enables the user to launch, schedule, modify, and remove a workflow or job template.
To create a new workflow job template:
Extra Variables:
Pass extra command line variables to the playbook. This is the “-e” or “–extra-vars” command line parameter for ansible-playbook that is documented in the Ansible documentation at Passing Variables on the Command Line.
Provide key/value pairs using either YAML or JSON. These variables have a maximum value of precedence and overrides other variables specified elsewhere. An example value might be:
git_branch: production release_version: 1.5For more information about extra variables, refer to Extra Variables.
Saving the template does not exit the Workflow Job Template page but remains on the Workflow Job Template Details view for further editing, if necessary. The Details tab of a saved template allows you to review, edit, and add permissions, notifications, surveys, or build a workflow job template using an editor.
You can verify the template is saved when the newly created workflow job template appears on the list of templates at the bottom of the screen.
Clicking on Permissions allows you to review, grant, edit, and remove associated permissions for users as well as team members.
Click the button to create new permissions for this workflow job template.
In this example, two users and one team have been selected and each have been granted permissions for this Workflow Template.
Note that you do not have to choose between teams or users, and that you can assign permissions to both at the same time.
Clicking on Notifications allows you to review any notification integrations you have setup.
Click on the button to create a notification.
Refer to Notifications for more information.
Workflows containing job types of Run or Check provide a way to set up surveys in the Workflow Job Template creation or editing screens. Surveys set extra variables for the playbook similar to ‘Prompt for Extra Variables’ does, but in a user-friendly question and answer way. Surveys also allow for validation of user input. Click the button to create a survey.
Use cases for surveys are numerous. An example might be if operations wanted to give developers a “push to stage” button they could run without advanced Ansible knowledge. When launched, this task could prompt for answers to questions such as, “What tag should we release?”
Many types of questions can be asked, including multiple-choice questions.
Note
Surveys are only available to those with Enterprise-level licenses.
To create a survey:
Use the ON/OFF toggle button at the top of the screen to quickly activate or deactivate this survey prompt.
A stylized version of the survey is presented in the Preview pane. For any question, you can click on the Edit button to edit the question, the Delete button to delete the question, and click and drag on the grid icon to rearrange the order of the questions.
The Required setting on a survey question determines whether the answer is optional or not for the user interacting with it.
Behind the scenes, optional survey variables can be passed to the playbook in extra_vars
, even when they aren’t filled in.
extra_var
is passed to the playbook.length > 0
, no survey extra_var
is passed to the playbook.length === 0
, that survey extra_var
is passed to the playbook, with the value set to an empty string ( “” ).Starting with Ansible Tower 3.1, the Workflow Editor provides a graphical way of linking together job templates, project syncs, and inventory syncs to build a workflow job template.
Make sure you have any combination of two of the following templates to build a workflow: jobs, project sync, or inventory sync.
A template that is associated with each workflow node will run based on the success or failure scenario as it proceeds.
- On Success: Upon successful completion, execute the next template.
- On Failure: Upon failure, execute a different template.
- Always: Continue to execute regardless of success or failure.
Hovering over the template allows you to delete the selected template , or add another one .
Note
If you create a workflow job template with any number of strung-together job templates or job/inventory syncs, and one of those are deleted from your inventory of resources (the resource no longer exists), returning to the Workflow Editor for the affected workflow job template will show the missing resource as an incomplete node.
To fix the incomplete node, update it with a new job template or delete it from the workflow.
You can insert another node in between nodes and drag the diagram to depict a split scenario:
If you want to undo the last inserted node, when the right pane opens, click Cancel or proceed to click on another node without selecting from the right pane.
If you want to edit a node, click on the node you want to edit and the right pane displays the current selections. Make your changes and click Select to apply them to the graphical view.
Below is an example of a workflow that contains all three types of jobs that is initiated by a job template that if it fails to run, proceed to the project sync job, and regardless of whether that fails or succeeds, proceed to the inventory sync job.
Use the Key at the top of the window to identify the meaning of the symbols and colors associated with the graphical depiction.
You may add multiple nodes from the same parent node, creating sibling nodes:
Note
In a workflow with a set of sibling steps having varying edge types, and one of those siblings has a follow-on step attached to it, gets removed from the workflow:
The follow-on step will automatically join the set of sibling steps. If there is more than one edge type among the now-siblings, an edge conflict occurs:
You must resolve this conflict before you can save the workflow job template. To resolve the conflict, make all the siblings have the same edge types.
Click the settings icon () to zoom, pan, or reposition the view. Drag the workflow diagram to reposition it on the screen.
Important
Clicking Close on this pane will not save your work, but instead, closes the entire Workflow Editor and you will have to start over.
To launch the workflow job template:
Along with any extra variables set in the job template and survey, Tower automatically adds the same variables as those added for a job template upon launch. Additionally, Tower automatically redirects the web browser to the Jobs Details page for this job, displaying the progress and the results.
Launching job templates may also be scheduled via the button. Clicking this button opens the Schedules page.
This page displays a list of the schedules that are currently available for the selected workflow job template. The schedule list may be sorted and searched by any of the following:
Buttons located in the upper right corner of the Schedules screen provide the following actions:
To create a new schedule:
Note
Jobs are scheduled in UTC. Repeating jobs that runs at a specific time of day may move relative to a local timezone when Daylight Saving Time shifts occur.
The Schedule Description below displays the specifics of the schedule and a list of the scheduled occurrences in the selected Local Time Zone.
Once the schedule is saved, the list of schedules display for the associated workflow job template.
Use the ON/OFF toggle button to quickly activate or deactivate this schedule.
There are several actions available for schedules, under the Actions column:
Ansible Tower allows you the ability to copy a workflow job template. If you choose to copy a workflow job template, it does not copy any associated schedule, notifications, or permissions. Schedules and notifications must be recreated by the user or admin creating the copy of the workflow job template. The user copying the workflow job template will be granted the admin permission, but no permissions are assigned (copied) to the workflow job template.
A new template opens with the name of the template from which you copied and a timestamp.
Replace the contents of the Name field with a new name, and provide or modify the entries in the other fields to complete this page.
Note
Additional strict extra_vars
validation was added in Ansible Tower 3.0.0. extra_vars
passed to the job launch API are only honored if one of the following is true:
ask_variables_on_launch
is set to TrueWhen you pass survey variables, they are passed as extra variables (extra_vars
) within Tower. This can be tricky, as passing extra variables to a workflow template (as you would do with a survey) can override other variables being passed from the inventory and project.
For example, say that you have a defined variable for an inventory for debug = true
. It is entirely possible that this variable, debug = true
, can be overridden in a workflow template survey.
To ensure that the variables you need to pass are not overridden, ensure they are included by redefining them in the survey. Keep in mind that extra variables can be defined at the inventory, group, and host levels.
The following table notes the behavior (hierarchy) of variable precedence in Ansible Tower as it compares to variable precedence in Ansible.
Ansible Tower Variable Precedence Hierarchy (last listed wins)