Bookmark this page

Guided Exercise: Configuring Automation Content Navigator

Edit an Ansible configuration file to customize your Ansible environment.

Outcomes

  • Generate an automation content navigator configuration file.

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

This command installs the required software, downloads an automation execution environment, and creates a project directory with the files needed for the exercise.

[student@workstation ~]$ lab start implement-navigator

Instructions

An automation content navigator configuration file simplifies the ansible-navigator commands that you use to run playbooks. Instead of repeatedly adding the same options on the command line, you can add those settings to the configuration file. Although you could memorize the syntax of the automation content navigator configuration file, this exercise demonstrates how to generate the file.

  1. Open the /home/student/implement-navigator directory in Visual Studio Code or change to that directory in a GNOME terminal. Complete the following substeps if you choose VS Code.

    1. In VS Code, click ViewExplorer and then click FileOpen Folder.

      Important

      If clicking FileOpen Folder does not appear to do anything, then VS Code probably opened the Open Folder window behind the current window. Click the date and time in the top bar and then click the Visual Studio Code notification.

    2. Navigate to Homeimplement-navigator and then click Open.

      Note

      If prompted, then select Trust the authors of all files in the parent folder 'student' and then click Yes, I trust the authors.

  2. Generate an automation content navigator configuration file that uses the existing settings.

    1. Use the ansible-navigator settings --effective command in a terminal to display the effective settings. Add the --eei and --pp options to specify an automation execution environment image and a pull policy. Redirect the command output into a file named sample.yml.

      [student@workstation implement-navigator] ansible-navigator settings \
      --effective --eei hub.lab.example.com/ee-supported-rhel8 \
      --pp missing > sample.yml

      Important

      If you redirect the output of the ansible-navigator settings command into a file named ansible-navigator.yml in the current directory, then the ansible-navigator command attempts to use the configuration file and ultimately fails.

    2. Rename the sample.yml file to ansible-navigator.yml.

      [student@workstation implement-navigator] mv sample.yml ansible-navigator.yml
  3. Update the ansible-navigator.yml file with the desired settings.

    1. Open the ansible-navigator.yml file in an editor.

    2. Remove lines from the file, add the highlighted inventory lines, and then update the highlighted playbook artifact line so that the file contains the following content. When finished, save the file.

      ---
      ansible-navigator:
        ansible:
          inventory:
            entries:
              - ./inventory 1
        execution-environment:
          image: hub.lab.example.com/ee-supported-rhel8:latest 2
          pull:
            policy: missing 3
        mode: stdout 4
        playbook-artifact:
          enable: false 5

      1

      If the Ansible configuration (such as an ansible.cfg file) defines an inventory, then the generated file adds an inventory entry with an absolute path. Because this exercise does not create or use an ansible.cfg file, add an entry for the project inventory file.

      2

      The generated file uses the value of the --eei option. If a tag is not specified, then the latest tag is added to the container image name.

      3

      The generated file uses the value of the --pp option.

      4

      The generated file always uses stdout mode. When prompting for a password, you must use stdout mode. Otherwise you can change the value to interactive mode if desired.

      5

      Playbook artifacts are enabled by default. Use a value of false if you need to prompt for a password, such as a connection password.

      Note

      This exercise removes lines so that you can focus on a small group of settings, but the lines do not need to be removed.

  4. Test the configuration file by using the ansible-navigator command to run the gather_facts.yml playbook. The value of your net_serialnum variable might be different from the following output:

    [student@workstation implement-navigator] ansible-navigator run gather_facts.yml
    ...output omitted...
            "net_hostname": "iosxe2.lab.example.com",
            "net_image": "bootflash:packages.conf",
            "net_iostype": "IOS-XE",
            "net_model": "C8000V",
            "net_operatingmode": "autonomous",
            "net_python_version": "3.9.13",
            "net_serialnum": "98U5E5QQ9AD",
            "net_system": "ios",
            "net_version": "17.06.02",
            "network_resources": {}
        }
    }
    
    PLAY RECAP *********************************************************************
    iosxe1.lab.example.com     : ok=2    changed=0    unreachable=0    failed=0  ...
    iosxe2.lab.example.com     : ok=2    changed=0    unreachable=0    failed=0  ...
  5. Either close the /home/student/implement-navigator directory in VS Code by selecting FileClose Folder, or return to the student home directory in a GNOME terminal by running the cd command.

    [student@workstation implement-navigator]$ cd

Finish

On the workstation machine, 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 implement-navigator

Revision: do457-2.3-7cfa22a