Bookmark this page

Guided Exercise: Back up, Configure, Recover from Errors, and Restore from Backups

Create a workflow job template consisting of a branching chain of jobs and launch it using the web UI of automation controller.

Outcomes

  • Create a workflow job template.

  • Run a job template when the previously run job template succeeds.

  • Run a job template when the previously run job template fails.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise, and to ensure that all required resources are available.

This command also creates the project, inventory, and credentials in automation controller so that you can complete the exercise.

[student@workstation ~]$ lab start task-workflow

Instructions

  1. Change to the ~/task-workflow directory. Run the ios_backup.yml playbook.

    1. In a terminal, change to the ~/task-workflow directory:

      [student@workstation ~]$ cd ~/task-workflow
    2. Run the ios_backup.yml playbook:

      [student@workstation task-workflow]$ ansible-navigator run ios_backup.yml
      
      PLAY [Backup IOS XE configurations] *******************************************
      
      TASK [Backup IOS XE configurations] *******************************************
      changed: [iosxe1.lab.example.com]
      changed: [iosxe2.lab.example.com]
      
      PLAY RECAP ********************************************************************
      iosxe1.lab.example.com     : ok=1    changed=1    unreachable=0    failed=0 ...
      iosxe2.lab.example.com     : ok=1    changed=1    unreachable=0    failed=0 ...
  2. Navigate to https://controller.lab.example.com and log in as admin using redhat as the password. Create a workflow job template named IOS - Add and Verify NTP that uses the Common inventory.

    1. Navigate to https://controller.lab.example.com and log in as admin using redhat as the password.

    2. Navigate to ResourcesTemplates and then click AddAdd workflow template. On the next page, add the following details and then click Save.

      FieldValue
      Name IOS - Add and Verify NTP
      Organization Default
      Inventory Common
  3. Add a Project Sync node named Synchronize Project to synchronize the IOS_NTP project.

    1. On the workflow visualizer page, click Start.

    2. On the Add Node page, select Project Sync in the Node Type list.

    3. Select the IOS_NTP project, scroll down to the Node Alias field, and enter Synchronize Project in that field.

    4. Click Save. On the workflow visualizer page under Synchronize Project, notice the P symbol that indicates it is a project sync node.

      Figure 5.8: Project synchronization node
  4. Add a Job Template node that launches the IOS - Add NTP Configuration job template to configure NTP if the Synchronize Project node succeeds.

    1. In the workflow visualizer, hover over the Synchronize Project node and click the + icon to add a new node.

    2. On the Run type page, select the On Success condition and then click Next.

    3. Select the IOS - Add NTP Configuration job template, scroll down to the Node Alias field, and enter Configure NTP in that field.

    4. Click Save. Notice the JT symbol, which indicates it is a job template node.

      Note

      You might need to increase the display resolution on the workstation machine, decrease the web browser zoom, or both, in order to see the entire visualizer display screen.

      If your mouse has a scroll wheel, then you can use the scroll wheel to zoom in and out of the visualizer.

  5. Add a job template node that launches the IOS - Verify NTP job template to verify that NTP is enabled if the Configure NTP node succeeds.

    1. In the workflow visualizer, hover over the Configure NTP node and then click the + icon to add a new node.

    2. On the Run type page, select the On Success condition and then click Next.

    3. Select the IOS - Verify NTP job template, scroll down to the Node Alias field, and enter Verify NTP in that field.

    4. Click Save.

  6. Add a job template node that launches the IOS - Revert NTP Configuration job template to revert the NTP configuration if the Configure NTP node fails.

    1. In the workflow visualizer, hover over the Configure NTP node and then click the + icon to add a new node.

    2. On the Run type page, select the On Failure condition and then click Next.

    3. Select the IOS - Revert NTP Configuration job template, scroll down to the Node Alias field, and enter Revert NTP Configuration in that field.

    4. Click Save.

    5. Click Save again in the upper-right corner to save this workflow template.

      Figure 5.9: Workflow job template
  7. Launch the workflow job template and observe the result. The Configure NTP node fails and triggers the Revert NTP Configuration node.

    1. Navigate to ResourcesTemplates.

    2. Click the Launch Template icon for the IOS - Add and Verify NTP workflow job template.

    3. Observe that the Configure NTP node fails and triggers the Revert NTP Configuration node.

    4. Click the Configure NTP node and then click the Output tab to determine the cause of the failure.

      The output indicates that the cisco.ios.ios_ntp_globla module is misspelled in the playbook.

  8. Fix the issue with the ntp.yml playbook.

    1. Create the ~/git-repos directory and then change to that directory. Clone the git repository into the ~/git-repos directory:

      [student@workstation task-workflow]$ mkdir -p ~/git-repos
      [student@workstation task-workflow]$ cd ~/git-repos
      [student@workstation git-repos]$ git clone \
      git@git.lab.example.com:student/ntp
      Cloning into 'ntp'...
      ...output omitted...
      [student@workstation git-repos]$ cd ntp
    2. Edit the ntp.yml file and fix the mistake in the playbook by changing cisco.ios.ios_ntp_globla to cisco.ios.ios_ntp_global as the module name. The modified playbook must consist of the following content:

      ---
      - name: Configure NTP on IOS managed nodes
        hosts: ios
        gather_facts: false
        tasks:
          - name: Configure NTP
            cisco.ios.ios_ntp_global:
              config:
                logging: true
                source: GigabitEthernet0/1
                servers:
                  - server: 10.10.100.1
                    version: 2
                  - server: 10.10.200.1
                    version: 2
              state: overridden
    3. Add, commit, and push the ntp.yml file:

      [student@workstation ntp]$ git add ntp.yml
      [student@workstation ntp]$ git commit -m "Fix typo in playbook"
      [student@workstation ntp]$ git push
  9. Launch the template through the automation controller web UI and verify that it now runs successfully. The Configure NTP node completes successfully and launches the Verify NTP node.

    1. Navigate to ResourcesTemplates.

    2. Click the Launch Template icon for the IOS - Add and Verify NTP workflow job template.

    3. The first step updates the project with the changes you have committed. Observe that this time the Configure NTP job template completes successfully and as a result the Verify NTP job template is launched.

  10. If you updated the ntp.yml playbook using VS Code, then click FileClose Folder in VS Code to close the /home/student/git-repos/ntp directory, or run the cd command in a GNOME terminal to return to the student home directory:

    [student@workstation ntp]$ cd

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish task-workflow

Revision: do457-2.3-7cfa22a