Bookmark this page

Guided Exercise: Performing Basic Troubleshooting of Automation Controller

  • 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

  1. 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.

  2. 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.

    1. Navigate to Settings in the automation controller.

    2. In the Settings window, under the Jobs category, click Jobs settings.

    3. Set Per-Host Ansible Fact Cache Timeout to 86400 seconds (one day), and then click Save.

  3. Create a new job template named Job Facts.

    1. Navigate to ResourcesTemplates and then click AddAdd job template to open the Create New Job Template page.

    2. Attempt to configure the new job template with the following details:

      FieldValue
      Name Job Facts
      Description Gather ansible facts from cluster
      Job Type Run
      Inventory Dev
      Project Job facts
      Playbook refresh_fact_cache.yml
      Credentials Developers

      When you try to do this, the refresh_fact_cache.yml playbook is not available. You need to troubleshoot this problem.

  4. 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.

    1. 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/
    2. 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.git
      Cloning into 'job-facts'...
      ...output omitted...
      [student@workstation git-repos]$ cd job-facts
      [student@workstation job-facts]$ ll
      total 12
      -rw-rw-r--. 1 student student  65 Jul  7 20:41 refresh_fact_cache.yml
      [student@workstation job-facts]$
  5. Because the playbook exists, that is not the problem. Playbooks that exist but do not appear in the Job Template list are most likely formatted incorrectly.

    Test the refresh_job_facts.yml playbook with the ansible-lint command, and repair any reported issues.

    1. 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...
    2. 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
    3. 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 main
      Enumerating objects: 5, done.
      Counting objects: 100% (5/5), done.
      ...output omitted...
      Branch 'main' set up to track remote branch 'main' from 'origin'.
  6. Synchronize the project to the automation controller.

    1. From the automation controller web UI, navigate to ResourcesProjects.

    2. Click the Sync Project icon for the Job facts project. Wait until the synchronization completes successfully.

  7. Attempt to add the refresh_fact_cache.yml playbook to the job template again.

    1. Navigate to ResourcesTemplates and click AddAdd job template to open the Create New Job Template page.

    2. Enter the following details. This time it should work. Click Save when you are finished.

      FieldValue
      Name Job Facts
      Description Gather ansible facts from cluster
      Job Type Run
      Inventory Dev
      Project Job facts
      Playbook refresh_fact_cache.yml
      Credentials Developers
    3. Select the Enable Fact Storage option and then click Save.

    4. Click Launch. The job should run successfully.

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 admin-troubleshoot

This concludes the section.

Revision: do467-2.2-08877c1