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.
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.
Navigate to https://controller.lab.example.com and log in as the admin user with redhat as the password.
Update the global job settings for automation controller to specify that cached facts are valid for one day (86,400 seconds).
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
| Field | Value |
|---|---|
Open additional networks?
| |
Open web access to selected networks.
| |
additional_networks
| |
| (not selected) | |
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)
|
Launch the Refresh Fact Cache job template to gather and cache facts about hosts in the Dev inventory.
Navigate to → and click the icon for the Refresh Fact Cache job template. Select the Dev inventory, click , and then click .
Wait until the job completes and then click the tab for the job. Verify that the job displays the status.
(Optional) Navigate to → and click the link for the host. Click the tab to view cached facts for the host.
Repeat this step for the host.
If you do not see host facts, then verify the Per-Host Ansible Fact Cache Timeout setting under → on the automation controller web UI. By default, the fact cache timeout is set to zero.
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.
Navigate to → and click the icon for the Internal Web Access job template.
Select the Dev inventory and then click .
In the survey window, select the 172.25.252.0/24 network from the menu and then click .
Click . 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.
Launch the Refresh Fact Cache job template to gather and cache facts about hosts in the Test inventory.
Navigate to → and click the icon for the Refresh Fact Cache job template. Select the Test inventory, click , and then click .
Wait until the job completes and then click the tab for the job. Verify that the job displays the status.
(Optional) Navigate to → and click the link for the host. Click the tab to view cached facts for the host.
Repeat this step for the host.
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.
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.
Navigate to → and click the icon for the job template.
Select the Test inventory and then click .
On the survey page, click to accept 172.25.252.0/24 as the additional network to open. Click .
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.