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 Ansible Automation Platform 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.

    templates link

  3. Click on the blue Create template button and select Create workflow job template.

    add workflow template button

  4. Fill out the form as follows:

    Parameter Value
    Name Workshop Workflow
    Organization Red Hat network organization
    Inventory Workshop Inventory
  5. Click on the blue Create workflow job template button

Step 2: The Workflow Visualizer

  1. When you clicked the Create workflow job template the Workflow visualizer should automatically open. If not click on the View workflow visualizer button.

    visualizer tab link

  2. By default only a blue Add step button will appear. Click on the Add step button.

    add step button

  3. The Add step window will appear.

add a template

Note:

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 three dots on the Backup network configurations node and click the Add step and link link.

    add step link

    The Add Step window will appear again.

  2. Fill out the following values:

Parameter Value
Node Type Job Template
Job template Network-Banner
Status Run on success
Convergence Any
Node alias

add second node

Note:

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. Click the blue Next button and fill out the survey field

    add network banner job template

  2. Click the blue Next button again, review, and then click the blue Finish button.

  3. A green line should exist between Backup network configurations and Network-Banner

    banner node

Step 4: Add the Configure Network-User Job Template

  1. Hover over the three dots on the Backup network configurations node and click the Add step and link link. (not the Network-Banner node)

  2. Fill out the following values:

    Parameter Value
    Node Type Job Template
    Job template Network-User
    Status Run on success
    Convergence Any
    Node alias

    select network user job

  3. Click the blue Next button and fill out the survey field (feel free to leave the defaults!)

    user survey

  4. Click Next, review then click Finish

    Your workflow should now look similar to the following image:

    configure user node

Step 5: Add the Network-Restore Job Template

  1. Hover over the Network-Banner node and click the three dots The Add step and link window will appear again.

  2. Fill out the following values:

    Parameter Value
    Node Type Job Template
    Job template Network Automation - Restore
    Status Run on fail
    Convergence Any
    Node alias

    Your forum should look similar to the following image:

    restore image

  3. Click the blue Next button for the Survey step, then choose a rollback date (Note: there may only be one choice if you only ran the backup one time)

  4. Click the blue Next button again, then review and click the Finish button.

    Your workflow should now look similar to the following image:

    configure restore node

  1. Hover over the Network-User node until a a small arrow appears to the right.

    arrow image

  2. Click on the arrow (it will turn gray), and drag it over to the Network Automation - Restore node

    on fail

  3. Now click on the Run always and change to Run on fail

    restore node

  4. Click Save, then click on the X to exit the visualizer.

    save button

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