Bookmark this page

Lab: Advanced Job Configuration

  • Enable fact caching, add a job template survey to an existing job template, and configure a job notification.

Outcomes

  • Create a job template that uses cached facts.

  • Create an associated survey and notification template.

  • Launch the job template from the automation controller web UI.

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

This command ensures that automation controller is installed and configured with any necessary resources created in previous exercises. The command also reverts the global settings for automation controller to the default value for cached facts.

[student@workstation ~]$ lab start job-review

Procedure 5.4. Instructions

A developer on your team committed playbook changes to a project repository. The playbook changes open firewall access to TCP port 80 to any network assigned to the additional_networks variable. You have been asked to add a survey to an existing job template that sets this variable and allows access to some of your internal networks.

After testing that the playbook changes and survey work for hosts in the Dev inventory, you must apply the changes to hosts in the Test inventory.

Note

The lab command changes the internal_apache_setup.yml playbook in the https://git.lab.example.com/git/internal_web.git Git repository. If you are interested in reviewing the changes, then you can clone the repository and run the git show -1 command to display details about the most recent commit.

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

  2. Update the global job settings for automation controller to specify that cached facts are valid for one day (86,400 seconds).

    1. Navigate to Settings and click the Job Settings link.

    2. Click Edit.

    3. Enter 86400 in the Per-Host Ansible Fact Cache Timeout field and then click Save.

  3. Add a new survey to the Internal Web Access job template. Add the survey using the following information and enable the survey.

    Table 5.1. New Survey

    FieldValue
    Question Open additional networks?
    Description Open web access to selected networks.
    Answer variable name additional_networks
    Answer Type Multiple Choice (multiple select)
    Required (not selected)
    Multiple Choice Options 192.168.0.0/24 (not selected as default) 192.168.100.0/24 (not selected as default) 172.25.252.0/24 (not selected as default)

    1. Navigate to ResourcesTemplates and click the link for the Internal Web Access job template.

    2. Click the Survey tab and then click Add.

    3. Create the survey using the information in the New Survey table. When finished, click Save.

    4. Click Survey Disabled and ensure that the label changes to Survey Enabled.

  4. Launch the Refresh Fact Cache job template to gather and cache facts about hosts in the Dev inventory.

    1. Navigate to ResourcesTemplates and click the Launch Template icon for the Refresh Fact Cache job template. Select the Dev inventory, click Next, and then click Launch.

    2. Wait until the job completes and then click the Details tab for the job. Verify that the job displays the Successful status.

    3. (Optional) Navigate to ResourcesHosts and click the link for the servera.lab.example.com host. Click the Facts tab to view cached facts for the host.

      Repeat this step for the serverb.lab.example.com host.

      Important

      If you do not see host facts, then verify the Per-Host Ansible Fact Cache Timeout setting under SettingsJob Settings on the automation controller web UI. By default, the fact cache timeout is set to zero.

  5. Launch the Internal Web Access job template to verify that the survey and the most recent Git repository changes work successfully. Target hosts in the Dev inventory and when prompted by the survey, select the 172.25.252.0/24 network.

    1. Navigate to ResourcesTemplates and click the Launch Template icon for the Internal Web Access job template.

    2. Select the Dev inventory and then click Next.

    3. In the survey window, select the 172.25.252.0/24 network from the menu and then click Next.

    4. Click Launch. The job succeeds and the Open ports for local network task displays the following output:

      TASK [Open ports for local network] ********************************************
      changed: [servera.lab.example.com] => (item=[{'port': 80, 'protocol': 'tcp'}, '172.25.250.0/24'])
      changed: [serverb.lab.example.com] => (item=[{'port': 80, 'protocol': 'tcp'}, '172.25.250.0/24'])
      changed: [servera.lab.example.com] => (item=[{'port': 80, 'protocol': 'tcp'}, '172.25.252.0/24'])
      changed: [serverb.lab.example.com] => (item=[{'port': 80, 'protocol': 'tcp'}, '172.25.252.0/24'])

      In addition to the 172.25.250.0/24 network (the network used by the eth0 interface on both hosts), the playbook opened TCP port 80 to the network specified by the survey.

  6. Launch the Refresh Fact Cache job template to gather and cache facts about hosts in the Test inventory.

    1. Navigate to ResourcesTemplates and click the Launch Template icon for the Refresh Fact Cache job template. Select the Test inventory, click Next, and then click Launch.

    2. Wait until the job completes and then click the Details tab for the job. Verify that the job displays the Successful status.

    3. (Optional) Navigate to ResourcesHosts and click the link for the serverc.lab.example.com host. Click the Facts tab to view cached facts for the host.

      Repeat this step for the serverd.lab.example.com host.

  7. Update the survey for the Internal Web Access job template to open TCP port 80 to the 172.25.252.0/24 network by default.

    1. Navigate to ResourcesTemplates and click the link for the Internal Web Access job template.

    2. Click the Survey tab and then click the Edit Survey icon for the Open additional networks? survey.

    3. Click the checkmark icon for the 172.25.252.0/24 network to make it a default answer for the survey. Click Save.

  8. Launch the Internal Web Access job template, target hosts in the Test inventory, and accept the default answer of using the 172.25.252.0/24 network.

    1. Navigate to ResourcesTemplates and click the Launch Template icon for the Internal Web Access job template.

    2. Select the Test inventory and then click Next.

    3. On the survey page, click Next to accept 172.25.252.0/24 as the additional network to open. Click Launch.

    4. Observe the live output of the running job. The job succeeds and the Open ports for local network task displays the following output:

      TASK [Open ports for local network] ********************************************
      changed: [serverd.lab.example.com] => (item=[{'port': 80, 'protocol': 'tcp'}, '172.25.250.0/24'])
      changed: [serverc.lab.example.com] => (item=[{'port': 80, 'protocol': 'tcp'}, '172.25.250.0/24'])
      changed: [serverd.lab.example.com] => (item=[{'port': 80, 'protocol': 'tcp'}, '172.25.252.0/24'])
      changed: [serverc.lab.example.com] => (item=[{'port': 80, 'protocol': 'tcp'}, '172.25.252.0/24'])

      In addition to the 172.25.250.0/24 network (the network used by the eth0 interface on both hosts), the playbook opened TCP port 80 access to the network specified by the survey.

      The web servers in the Test environment now match the web servers in the Dev environment.

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 job-review

This concludes the section.

Revision: do467-2.2-08877c1