EX294 4.3: Navigator inventories and settings
Make ansible-navigator see the same inventory and ansible.cfg as
Ansible does, and give its execution environment a roles directory from
outside the project.
Before you start
This VM is the control node. The lab creates the user greg (password
Lab-Pass-1) with an SSH key, and installs ansible-core and
ansible-navigator (from PyPI, in /opt/le-lab-navigator). Work as
greg, in /home/greg/ansible: its ansible.cfg reads the inventory
inventory, logs in as devops and becomes root. Its
ansible-navigator.yml uses the execution environment image
localhost/lab-ee:2.16 (built on this VM from AlmaLinux 10's ansible-core
and collections from Ansible Galaxy; no registry or login) in stdout mode,
but someone left two more settings in it.
greg also has a role, banner, in /home/greg/roles, outside the
project, and the project's banner.yml applies it to every node.
The managed nodes node1 (10.99.1.11) and node2 (10.99.1.12) are
AlmaLinux 10 containers reached over SSH by name; on both, devops
accepts greg's key and may use sudo without a password. For a root shell
on a node, sudo podman exec -it node1 bash.
Tasks
- Show the inventory's groups with ansible-navigator, in stdout mode and
in the interactive browser, and make them match:
ansible-navigator inventory -m stdout --graphprints the same asansible-inventory --graph. - Find which
ansible.cfgansible-navigator uses, and make it the project's:ansible-navigator config dump --only-changed -m stdoutshowsCONFIG_FILE() = /home/greg/ansible/ansible.cfg. - Set
roles_pathin the project'sansible.cfgto/home/greg/rolesand runbanner.ymlwith navigator: it fails with "the role 'banner' was not found". Fix it with a volume mount inansible-navigator.yml, so the run succeeds and every node has/etc/motd.d/banner.
Hints
ansible-navigator settings --effective --sources -m stdoutsays where each setting came from: look atansible.config.pathandansible.inventory.entries.ansible-navigator inventory -m interactive: numbers open a view, Esc goes back,:qquits.execution-environment: volume-mounts:takes a list ofsrc,destandoptions(Zrelabels the directory for SELinux).