Troubleshoot and identify a problem with the configuration of a playbook for a new job template.
Outcomes
Fix a problem in which automation controller does not show a playbook that you want to add to a new job template.
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.
[student@workstation ~]$ lab start admin-troubleshoot
Procedure 9.1. Instructions
In this exercise, you need to create a new job template named Job Facts that uses the refresh_fact_cache.yml playbook from the existing Job facts project to refresh the fact cache for managed hosts in the Dev inventory.
Navigate to https://controller.lab.example.com and log in as the admin user with redhat as the password.
Make sure that the per-host Ansible fact cache timeout for automation controller is set for exactly one day (86400 seconds). This ensures that the facts are cached for hosts but also expire if the facts have not been refreshed recently.
Navigate to in the automation controller.
In the window, under the category, click .
Set to 86400 seconds (one day), and then click .
Create a new job template named Job Facts.
Navigate to → and then click → to open the page.
Attempt to configure the new job template with the following details:
| Field | Value |
|---|---|
Job Facts
| |
Gather ansible facts from cluster
| |
When you try to do this, the refresh_fact_cache.yml playbook is not available. You need to troubleshoot this problem.
The most likely cause for this issue is that the playbook is not present in the Git repository. Make sure that the refresh_fact_cache.yml playbook is present in the job-facts repository.
From a terminal, create the /home/student/git-repos directory if it does not already exist, and then change into it.
[student@workstation ~]$mkdir -p ~/git-repos/[student@workstation ~]$cd ~/git-repos/
Clone the https://git.lab.example.com/git/job-facts.git repository and then review the contents.
Verify that the refresh_fact_cache.yml playbook is present.
[student@workstation git-repos]$git clone \>https://git.lab.example.com/git/job-facts.gitCloning into 'job-facts'... ...output omitted... [student@workstation git-repos]$cd job-facts[student@workstation job-facts]$lltotal 12 -rw-rw-r--. 1 student student 65 Jul 7 20:41refresh_fact_cache.yml[student@workstation job-facts]$
Because the playbook exists, that is not the problem. Playbooks that exist but do not appear in the list are most likely formatted incorrectly.
Test the refresh_job_facts.yml playbook with the ansible-lint command, and repair any reported issues.
Run the ansible-lint command on the file to search for formatting errors.
[student@workstation job-facts]$ansible-lint -p refresh_fact_cache.yml...output omitted... refresh_fact_cache.yml:2:3: syntax-check 'host' is not a valid attribute for a Play ...output omitted...
Edit the refresh_fact_cache.yml playbook and fix the mistake. The play in the playbook has a typing mistake. After you edit it, the playbook should have the following contents:
--- - name: Refresh fact cache hosts: all gather_facts: true
Use the git add command to stage the changes, and then commit the changes using Fixed a mistake in hosts as the commit message. Push the locally committed changes to the remote server.
[student@workstation job-facts]$git add refresh_fact_cache.yml[student@workstation job-facts]$git commit -m "Fixed a mistake in hosts"[main e76b744] Fixed a mistake in hosts. 1 file changed, 1 insertion(+), 1 deletion(-) [student@workstation job-facts]$git push -u origin mainEnumerating objects: 5, done. Counting objects: 100% (5/5), done. ...output omitted... Branch 'main' set up to track remote branch 'main' from 'origin'.
Synchronize the project to the automation controller.
From the automation controller web UI, navigate to → .
Click the icon for the Job facts project. Wait until the synchronization completes successfully.
Attempt to add the refresh_fact_cache.yml playbook to the job template again.
Navigate to → and click → to open the page.
Enter the following details. This time it should work. Click when you are finished.
| Field | Value |
|---|---|
Job Facts
| |
Gather ansible facts from cluster
| |
Select the option and then click .
Click . The job should run successfully.