Exercise 9: Creating a Workflow

Read this in other languages: uk English, japan 日本語, Español Español.

Table of Contents

Objective

Demonstrate the use of Automation Controller workflow. Workflows allow you to configure a sequence of disparate job templates (or workflow templates) that may or may not share inventory, playbooks, or permissions.

For this exercise we will create a time-stamped backup, if the backup job successfully completes the workflow will simultaneously configure a banner and a user. If either job template fails we will restore to the time stamped backup.

Guide

Step 1: Create a workflow template

  1. Make sure you are logged in as the admin user.

  2. Click on the Templates link on the left menu.

  3. Click on the blue Add button and select Add workflow template.

    add workflow template button

  4. Fill out the form as follows:

    Parameter Value
    Name Workshop Workflow
    Organization Default
    Inventory Workshop Inventory
  5. Click on the blue Save button

Step 2: The Workflow Visualizer

  1. When you click the Save the Workflow visualizer should automatically open. If not click on the Visualizer tab.

    visualizer tab link

  2. By default only a green Start button will appear. Click on the Start button.

  3. The Add Node window will appear.

add a template

The Backup network configurations job template is now a node. Job or workflow templates are linked together using a graph-like structure called nodes. These nodes can be approvals, jobs, project syncs, inventory syncs, or even other workflows. A template can be part of different workflows or used multiple times in the same workflow.

configure backup node

Step 3: Add the Configure Banner Job Template

  1. Hover over the Backup network configurations node and click the + symbol. The Add Node window will appear again.

  2. For the Run type select On Success from the drop down menu. Press the blue Next button.

add second node

Workflows can be configured to run automation jobs when the previous node succeeds, fails, or have it always run no matter what the previous job did. This allows workflows to fix issues or revert the state of a device.
  1. Select the Network-Banner Job Template.

    add network banner job template

    • Click the blue Next button
  2. Fill out the Survey similar to exercise 7.

    enter banner text

  3. Click Next and then Save.

  4. A green line should exist between Backup network configurations and Configure Banner

    banner node

Step 4: Add the Configure Network-User Job Template

  1. Hover over the Backup network configurations node (not the Configure Banner node) and click the + symbol. The Add Node will appear again.

  2. For the Run type select On Success from the drop down menu. Press the blue Next button.

    add second node

  3. Select the Network-User Job Template.

    select network user job

  4. Fill out the survey (or just let it default to configure the ansible user

  5. Click Next and Save

    configure user node

Step 5: Add the Network-Restore Job Template

  1. Hover over the Network-Banner node and click the + symbol. The Add Node window will appear again.

  2. Select On Failure for Run type

    on failure run type

    • Click Next
  3. Select the Network-Restore job template.

    add restore

  4. Select a rollback date and click Next and Save

    configure restore node

  1. Hover over the Network-User node and click the chain chain symbol.

  2. Now, double click on the existing Network-Restore. A Add Link window will appear. For the RUN parameter choose On Failure.

    on fail

    • Click Save
  3. Now your workflow should look like the following:

    restore node

  4. Click Save to exit the visualizer.

Step 7: Run the Workflow

  1. Click Launch button.

    launch workflow

  2. Watch the Workshop Workflow.

    workflow job launched

    At any time during the workflow job you can select an individual job template by clicking on the node to see the status.

Takeaways

You have

Complete

You have completed lab exercise 9. This concludes the Network Automation workshop. Thank you for attending!

For additional supplemental exercises check out Supplemental Exercises


Previous Exercise

Click here to return to the Ansible Network Automation Workshop