Bookmark this page

Lab: Configuring Workflow Job Templates, Surveys, and Notifications

  • Create a workflow job template that uses a survey and sends email notifications.

Outcomes

  • Add a survey to an existing job template.

  • Create a notification template using the Email notification type.

  • Create a workflow job template and associate it to the notification template.

  • Launch and approve the workflow job template.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command prepares your environment and ensures that all required resources are available.

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

Specifications

In this activity, you create a workflow job template on your automation controller. You can log in to your automation controller at https://controller.lab.example.com as the admin user with redhat as the password.

The lab start compreview-workflow command creates two job templates, MOTD Update and Network Performance Improvements. The Network Performance Improvements job template sets some sysctl kernel tunables (net.core.netdev_max_backlog and net.core.netdev_budget) for the hosts on which it runs. The MOTD Update job template updates the message of the day file (/etc/motd).

The lab start compreview-workflow command also creates two inventories: Dev for development machines (servera.lab.example.com and serverb.lab.example.com) and Prod for production machines (servere.lab.example.com and serverf.lab.example.com).

Configure a new workflow job template, named Improving Network Performance from Dev to Prod, based on the following specification:

  • Add a survey to the MOTD Update job template using the following information. When done, enable the survey.

    FieldValue
    Question What is the performance status for this system?
    Answer variable name performance_message
    Answer type Multiple Choice (single select)
    Required (selected)
    Multiple Choice Options

    System has NOT been customized to improve network performance. (selected)

    System has been customized to improve network performance.

  • Create a notification template using the following information.

    FieldValue
    Name Email AAP Admins
    Description Sends an email to notify the status of the job
    Organization Default
    Type E-mail
    Host localhost
    Recipient list aap-admins@lab.example.com
    Sender e-mail system@controller.lab.example.com
    Port 25
    Timeout 30
  • Create a workflow job template named Improving Network Performance from Dev to Prod in the Default organization. Structure it as shown in the following diagram.

    Figure 12.15: The workflow job template
  • Set up the first node in the workflow job template to deploy performance improvements to development nodes, based on the following information.

    Table 12.1. Node: Performance Improve (D)

    FieldValue
    Node Type Job Template
    Name Network Performance Improvements
    Node Alias Performance Improve (D)
    Inventory Dev

  • The On failure MOTD (D) node runs if the first node (Performance Improve (D)) fails. Configure it based on the information in the following table.

    Table 12.2. Node: On failure MOTD (D)

    FieldValue
    Node Type Job Template
    Name MOTD Update
    Node Alias On failure MOTD (D)
    Inventory Dev
    Survey Answer System has NOT been customized to improve network performance.

  • If the first node (Performance Improve (D)) succeeds, then the workflow launches two nodes that are configured based on the following information.

    Table 12.3. Node: On success MOTD (D)

    FieldValue
    Node Type Job Template
    Name MOTD Update
    Node Alias On success MOTD (D)
    Inventory Dev
    Survey Answer System has been customized to improve network performance.

    Table 12.4. Node: Approval

    FieldValue
    Node Type Approval
    Name Approval
    Description Pushing to Prod requires approval
    Timeout (min) 60

  • If the approval node succeeds, then deploy performance improvements to production nodes based on the following information:

    Table 12.5. Node: Performance Improve (P)

    FieldValue
    Node Type Job Template
    Name Network Performance Improvements
    Node Alias Performance Improve (P)
    Inventory Prod

  • If the Performance Improve (P) node succeeds, then launch the MOTD Update job template for production nodes based on the following information:

    Table 12.6. Node: On success MOTD (P)

    FieldValue
    Node Type Job Template
    Name MOTD Update
    Node Alias On success MOTD (P)
    Inventory Prod
    Survey Answer System has been customized to improve network performance.

  • Configure your Improving Network Performance from Dev to Prod workflow job template with success and failure notifications using the Email AAP Admins notification template previously discussed in this specification. Do not enable notifications for the Approval or Start options.

  • To confirm that your workflow job template is correctly configured:

    Launch the Improving Network Performance from Dev to Prod workflow job template and approve it when required.

    Verify that the completion of the workflow job template triggers an email notification. The student user can access these emails by using ssh to log in to utility.lab.example.com and inspecting the file /var/mail/student, or by installing and using the mutt command to read the mail messages. The password for the student user is student.

    Verify that the managed hosts listed in the Dev and Prod inventories display an updated MOTD on login, and that the net.core.netdev_max_backlog and net.core.netdev_budget kernel tunables were modified.

    If everything worked, the MOTD should be updated to System has been customized to improve network performance., the net.core.netdev_max_backlog kernel parameter should have a value of 600, and the net.core.netdev_budget kernel parameter should have a value of 10000.

  1. Navigate to https://controller.lab.example.com and log in as the admin user with redhat as the password. Verify that the lab start compreview-workflow command created the MOTD Update and Network Performance Improvements job templates, as well as the Dev and Prod inventories.

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

    2. Navigate to ResourcesTemplates, then verify that MOTD Update and Network Performance Improvements are in the list of job templates.

    3. Navigate to ResourcesInventories, then verify that Dev and Prod are in the list of inventories.

  2. Add a survey to the MOTD Update job template using the following information. When done, enable the survey.

    FieldValue
    Question What is the performance status for this system?
    Answer variable name performance_message
    Answer type Multiple Choice (single select)
    Required (selected)
    Multiple Choice Options

    System has NOT been customized to improve network performance. (selected)

    System has been customized to improve network performance.

    1. Navigate to ResourcesTemplates in automation controller.

    2. Click the MOTD Update link.

    3. Click the Survey tab.

    4. Click Add to add a survey.

    5. Add a question to the survey using the information from the table. When finished, click Save.

    6. Click Survey Disabled and verify that the label changes to Survey Enabled.

  3. Create a notification template using the following information. When finished, click Save. Then, send a test notification to validate that it is working.

    FieldValue
    Name Email AAP Admins
    Description Sends an email to notify the status of the job
    Organization Default
    Type E-mail
    Host localhost
    Recipient list aap-admins@lab.example.com
    Sender e-mail system@controller.lab.example.com
    Port 25
    Timeout 30
    1. Navigate to AdministrationNotifications.

    2. Click Add to create a notification template.

    3. Use the information from the table to create the notification template. When finished, click Save.

    4. Click Test to test the notification process. Then, click the Back to Notifications tab. After some seconds, the Status column displays the Successful message.

  4. Create a workflow job template named Improving Network Performance from Dev to Prod in the Default organization. Then, create the first node in the workflow job template using the following information.

    FieldValue
    Node Type Job Template
    Name Network Performance Improvements
    Node Alias Performance Improve (D)
    Inventory Dev
    1. Navigate to ResourcesTemplates.

    2. Click AddAdd workflow template.

    3. Fill in the details using the following information, and then click Save.

      FieldValue
      Name Improving Network Performance from Dev to Prod
      Organization Default
    4. Click Start to add the first workflow job template node using the workflow visualizer.

    5. In the Node Type list, choose Job Template and select the Network Performance Improvements job template.

    6. Scroll to the bottom of the page and enter Performance Improve (D) in the Node Alias field. Click Next when done.

    7. Select the Dev inventory. Click Next when done.

    8. Click Save to save the node. Save information about the node, but do not save the workflow job template yet.

  5. If the Performance Improve (D) node fails, then the workflow job template must launch a job template that updates the MOTD in the development environment hosts. Use the information in the table to create the node. Leave the default answer for the survey, indicating that the system has not been customized to improve the network performance. Save information about the node, but do not save the workflow job template yet.

    FieldValue
    Node Type Job Template
    Name MOTD Update
    Node Alias On failure MOTD (D)
    Inventory Dev
    Survey Answer System has NOT been customized to improve network performance.
    1. Without leaving the workflow visualizer, hover over the Performance Improve (D) node and click Add a new node.

    2. Select On Failure and click Next.

    3. In the Node Type list, choose Job Template and select the MOTD Update job template.

    4. Scroll to the bottom of the page and enter On failure MOTD (D) in the Node Alias field. Click Next when done.

    5. Select the Dev inventory and click Next.

    6. Leave the default answer for the survey untouched and click Next.

    7. Click Save to save the node. Save information about the node, but do not save the workflow job template yet.

      Figure 12.16: Workflow job template after adding the 'On failure' node.
  6. If the Performance Improve (D) node succeeds, then the workflow must launch two nodes. Use the information in the following table to create the first of the two nodes. Make sure that you add this node subsequent to the Performance Improve (D) node. Save information about the node, but do not save the workflow job template yet.

    FieldValue
    Node Type Job Template
    Name MOTD Update
    Node Alias On success MOTD (D)
    Inventory Dev
    Survey Answer System has been customized to improve network performance.
    1. Without leaving the workflow visualizer, hover over the Performance Improve (D) node and click Add a new node.

    2. This time, select On Success and click Next.

    3. In the Node Type list, choose Job Template and select the MOTD Update job template.

    4. Scroll to the bottom of the page and enter On success MOTD (D) in the Node Alias field. Click Next when done.

    5. Select the Dev inventory and click Next.

    6. On the survey page, select the System has been customized to improve network performance. answer, and then click Next.

    7. Click Save to save the node, but do not save the workflow job template yet.

  7. Use the information in the following table to add a new node to the workflow. Make sure that you add it subsequent to the Performance Improve (D) node. Save information about the node, but do not save the workflow job template yet.

    FieldValue
    Node Type Approval
    Name Approval
    Description Pushing to Prod requires approval
    Timeout (min) 60
    1. Without leaving the workflow visualizer, hover over the Performance Improve (D) node and click Add a new node.

    2. Select On Success and click Next.

    3. Choose Approval in the Node Type list.

    4. Enter Approval in the Name field.

    5. Enter Pushing to Prod requires approval in the description of the node.

    6. Modify the Timeout field to 60 minutes.

    7. Click Save to save the node, but do not save the workflow job template yet.

      Figure 12.17: Workflow job template after adding the 'On success' nodes
  8. If the Approval node succeeds, the workflow job template must launch a job template that improves the network performance in your production environment. Create the node using the following information. Save information about the node, but do not save the workflow job template yet.

    FieldValue
    Node Type Job Template
    Name Network Performance Improvements
    Node Alias Performance Improve (P)
    Inventory Prod
    1. Without leaving the workflow visualizer, hover over the Approval node and click Add a new node.

    2. Select On Success and click Next.

    3. In the Node Type list, choose Job Template and elect the Network Performance Improvements job template.

    4. Scroll to the bottom of the page and enter Performance Improve (P) in the Node Alias field. Click Next.

    5. Select the Prod inventory. Click Next.

    6. Click Save to save the workflow job template node. Save information about the node, but do not save the workflow job template yet.

  9. If the Performance Improve (P) node succeeds, the workflow job template must launch a job template that updates the MOTD in the production environment hosts. This is the final node in the workflow job template. Use the following information to create the node. Then, save the node and save the workflow job template.

    FieldValue
    Node Type Job Template
    Name MOTD Update
    Node Alias On success MOTD (P)
    Inventory Prod
    Survey Answer System has been customized to improve network performance.
    1. Without leaving the workflow visualizer, hover over the Performance Improve (P) node and click Add a new node.

    2. Select On Success and click Next.

    3. In the Node Type list, choose Job Template and select the MOTD Update job template.

    4. Scroll to the bottom of the page and enter On success MOTD (P) in the Node Alias field. Click Next when done.

    5. Select the Prod inventory and click Next.

    6. On the survey page, select System has been customized to improve network performance. ,and then click Next.

    7. Click Save to save the node, and then click Save to save the workflow job template.

      Figure 12.18: The complete workflow job template
  10. Configure the Improving Network Performance from Dev to Prod workflow job template to use the Email AAP Admins notification template. Activate the Success and Failure notifications. Leave the Approval and Start options untouched.

    1. Navigate to ResourcesTemplates.

    2. Click the Improving Network Performance from Dev to Prod link.

    3. Click the Notifications tab.

    4. Set the Success and Failure switches to on for the Email AAP Admins notification. Leave the Approval and Start options untouched.

  11. Test your work by launching the Improving Network Performance from Dev to Prod workflow job template and approving it when the approval node runs.

    1. Navigate to ResourcesTemplates.

    2. Click the Launch Template icon for the Improving Network Performance from Dev to Prod workflow job template.

    3. Observe that the workflow stops at the approval node. Click the notification icon that appears at the top of the page when the workflow stops at the approval node.

    4. Select the checkbox for the Approval in the workflow job template.

    5. Click Approve to approve the execution of the remaining workflow job template nodes.

    6. Navigate to ViewsJobs and wait for the Status column to display Successful in the job for the Improving Network Performance from Dev to Prod workflow job template.

  12. Verify that the Email AAP Admins notification template sent email to the aap-admins@lab.example.com email alias to report the success of the completed job. The student user can access these emails on the utility server.

    1. Open a terminal and connect to the utility server.

      [student@workstation ~]$ ssh student@utility
    2. Use the tail command to see the email that was sent by automation controller to report the success of the completed job. Your message looks similar to the following:

      [student@utility ~]$ tail /var/mail/student
          "name": "Improving Network Performance from Dev to Prod",
          "url": "https://controller.lab.example.com/#/jobs/workflow/9",
          "created_by": "admin",
          "started": "2022-07-28T23:34:10.961830+00:00",
          "finished": "2022-07-28T23:34:50.959933+00:00",
          "status": "successful",
          "traceback": "",
          "body": "Workflow job summary:\n\n- node #7 spawns no job.\n- node #9 spawns job #10, \"Network Performance Improvements\", which finished with status successful.\n- node #8 spawns job #11, \"MOTD Update\", which finished with status successful.\n- node #12 spawns job #12, \"Approval\", which finished with status successful.\n- node #11 spawns job #13, \"Network Performance Improvements\", which finished with status successful.\n- node #10 spawns job #14, \"MOTD Update\", which finished with status successful."
      }
      
      [student@utility ~]$
    3. Exit the terminal session on the utility system.

      [student@workstation ~]$ exit
  13. Confirm that after running your workflow job template, the MOTD and the net.core.netdev_max_backlog and net.core.netdev_budget kernel tunables are modified on the managed hosts in the Dev and Prod inventories.

    Now, the net.core.netdev_max_backlog kernel parameter should have a value of 10000 and the net.core.netdev_budget kernel parameter should now have a value of 600.

    1. From a terminal window, connect to servera.lab.example.com. Confirm that the message of the day is System has been customized to improve network performance.

      [student@workstation ~]$ ssh student@servera.lab.example.com
      ...output omitted..
      System has been customized to improve network performance.
      ...output omitted...
      [student@servera ~]$
    2. Use the sudo command to change to the root user, using student as the password. Then, verify the values for the net.core.netdev_max_backlog and net.core.netdev_budget kernel tunables.

      [student@servera ~]$ sudo -i
      [sudo] password for student: student
      [root@servera ~]# sysctl net.core.netdev_max_backlog net.core.netdev_budget
      net.core.netdev_max_backlog = 10000
      net.core.netdev_budget = 600
      [root@servera ~]#
    3. Log out of the servera machine.

      [root@servera ~]# exit
      logout
      [student@servera ~]$ exit
      logout
      Connection to servera.lab.example.com closed.
      [student@workstation ~]$
    4. Connect to serverf.lab.example.com and observe the message of the day, if any.

      [student@workstation ~]$ ssh student@serverf.lab.example.com
      ...output omitted..
      System has been customized to improve network performance.
      ...output omitted...
      [student@serverf ~]$
    5. Use the sudo command to change to the root user, using student as the password. Then, verify the value for the net.core.netdev_max_backlog and net.core.netdev_budget kernel tunables.

      [student@serverf ~]$ sudo -i
      [sudo] password for student: student
      [root@serverf ~]# sysctl net.core.netdev_max_backlog net.core.netdev_budget
      net.core.netdev_max_backlog = 10000
      net.core.netdev_budget = 600
      [root@serverf ~]#
    6. Log out of the serverf machine.

      [root@serverf ~]# exit
      logout
      [student@serverf ~]$ exit
      logout
      Connection to serverf.lab.example.com closed.
      [student@workstation ~]$

Finish

On the workstation machine, change to the student user home directory and 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 compreview-workflow

This concludes the section.

Revision: do467-2.2-08877c1