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.
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.
In VS Code, click → and then click → .
If clicking → does not appear to do anything, then VS Code probably opened the window behind the current window. Click the date and time in the top bar and then click the notification.
Navigate to → and then click .
If prompted, then select and then click .
Generate an automation content navigator configuration file that uses the existing settings.
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
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.
Rename the sample.yml file to ansible-navigator.yml.
[student@workstation implement-navigator] mv sample.yml ansible-navigator.ymlUpdate the ansible-navigator.yml file with the desired settings.
Open the ansible-navigator.yml file in an editor.
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
execution-environment:
image: hub.lab.example.com/ee-supported-rhel8:latest
pull:
policy: missing
mode: stdout
playbook-artifact:
enable: false 
If the Ansible configuration (such as an | |
The generated file uses the value of the | |
The generated file uses the value of the | |
The generated file always uses | |
Playbook artifacts are enabled by default.
Use a value of |
This exercise removes lines so that you can focus on a small group of settings, but the lines do not need to be removed.
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 ...Either close the /home/student/implement-navigator directory in VS Code by selecting → , or return to the student home directory in a GNOME terminal by running the cd command.
[student@workstation implement-navigator]$ cd