Ansible: From Introduction to Abandonment (Part 16)

Last time we discussed two subcommands of Ansible-navigator: exec and run. Here, we will introduce five more subcommands of Ansible-navigator (and there are 5 more to write about next time).

Ansible-navigator welcome

<span>ansible-navigator welcome</span> starts an interactive interface similar to a help document for quickly understanding the usage of <span>ansible-navigator</span>.

[root@ansible-controller ansible-navigator]# ansible-navigator welcome \
    --eei quay.io/ansible/awx-ee:24.6.1 -m interactive
 0│Welcome
 1│————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
 2│
 3│Some things you can try from here:
 4│- :collections                                    Explore available collections
 5│- :config                                         Explore the current ansible configuration
 6│- :doc <plugin>                                   Review documentation for a module or plugin
 7│- :help                                           Show the main help page
 8│- :images                                         Explore execution environment images
 9│- :inventory -i <inventory>                       Explore an inventory
10│- :log                                            Review the application log
11│- :lint <file or directory>                       Lint Ansible/YAML files (experimental)
12│- :open                                           Open current page in the editor
13│- :replay                                         Explore a previous run using a playbook artifact
14│- :run <playbook> -i <inventory>                  Run a playbook in interactive mode
15│- :settings                                       Review the current ansible-navigator settings
16│- :quit                                           Quit the application
17│
18│happy automating,
19│
20│-winston

<span>ansible-navigator welcome</span> can only run in interactive mode.

Ansible-navigator doc

<span>ansible-navigator doc</span> executes the <span>ansible-doc</span> command through a container.

Available options:

Option / Parameter Name Type Default Value Description
<span>--hd</span>, <span>--help-doc</span> <span>bool</span> None Controls whether to display the help information of <span>ansible-doc</span> in standard output (<span>true</span> or <span>false</span>).
<span>plugin_name</span> <span>str</span> None Specify the name of the plugin to view documentation for, such as <span>copy</span>, <span>ping</span>, <span>lineinfile</span>, etc.
<span>-t</span>, <span>--type</span> <span>str</span> <span>module</span> Specify the plugin type, such as:<span>become</span>, <span>callback</span>, <span>inventory</span>, <span>lookup</span>, <span>module</span>, <span>role</span>, etc.

Supported plugin types include:

  • <span>become</span>: Privilege escalation plugin
  • <span>cache</span>: Caching plugin
  • <span>callback</span>: Callback plugin (e.g., JSON, YAML output)
  • <span>cliconf</span>: Network device CLI plugin
  • <span>connection</span>: Connection plugin (e.g., <span>ssh</span>, <span>local</span>)
  • <span>filter</span>: Jinja2 filter plugin
  • <span>httpapi</span>: HTTP API plugin
  • <span>inventory</span>: Inventory plugin
  • <span>keyword</span>: Keyword plugin (rarely used)
  • <span>lookup</span>: Lookup plugin (e.g., <span>env</span>, <span>file</span>)
  • <span>module</span>: Module (core functionality of Ansible)
  • <span>netconf</span>: Network device NETCONF plugin
  • <span>role</span>: Role
  • <span>shell</span>: Shell plugin
  • <span>strategy</span>: Execution strategy plugin (e.g., <span>linear</span>, <span>free</span>)
  • <span>test</span>: Jinja2 test plugin
  • <span>vars</span>: Variable plugin

This also differentiates between interactive and non-interactive modes; in interactive mode, you can only view the help documentation for a specific plugin, while others can only be viewed in non-interactive mode:

# View help
[root@ansible-controller ansible-navigator]# ansible-navigator doc --hd

# Interactive run, view help documentation for a specific plugin
[root@ansible-controller ansible-navigator]# ansible-navigator \
    --eei quay.io/ansible/awx-ee:24.6.1 -m interactive doc ansible.builtin.ping

# Non-interactive run, list plugins of type module
[root@ansible-controller ansible-navigator]# ansible-navigator \
    --eei quay.io/ansible/awx-ee:24.6.1 -m stdout doc -t module -l

Ansible-navigator images

<span>ansible-navigator images</span> is used to view available container execution environment images and see detailed information.

Option Type Default Value Description
<span>--fmt</span>, <span>--format</span> <span>str</span> <span>yaml</span> Specify the output format, options include:<span>json</span> or <span>yaml</span>, controlling the format of stdout output.
<span>-d</span>, <span>--details</span> <span>str</span> <span>everything</span> Specify the content of execution environment details to display, options include:
  • <span>ansible_collections</span>: Installed Ansible collections
  • <span>ansible_version</span>: Version of Ansible
  • <span>os_release</span>: Base operating system information
  • <span>python_packages</span>: Python package information
  • <span>python_version</span>: Python version
  • <span>redhat_release</span>: Red Hat version (if applicable)
  • <span>system_packages</span>: System package information
  • <span>everything</span>: All information (default)
# View all available image information in interactive mode
[root@ansible-controller ansible-navigator]# ansible-navigator \
    --eei quay.io/ansible/awx-ee:24.6.1 -m interactive images
  Image                           Tag       Execution environment     Created         Size
0│ansible-ee-rocky8.10-py3.9      2.12.10   True                      13 days ago     231 MB
1│awx-ee                          24.6.1    True                      11 months ago   1.84 GB
2│community-ansible-dev-tools     latest    True                      3 days ago      1.3 GB
3│community-ee-base               2.17.3-1  True                      8 months ago    344 MB
4│fedora41-test-container         9.2.0     False                     4 months ago    610 MB
# Here you can see that the first four images support ansible-navigator

# View information about a specific image in non-interactive mode
[root@ansible-controller ansible-navigator]# ansible-navigator images \
    --mode stdout --eei ghcr.io/ansible-community/ansible-community/community-ee-base:2.17.3-1 \
    -d os_release -d python_version --fmt yaml
---
image_name: ghcr.io/ansible-community/ansible-community/community-ee-base:2.17.3-1
os_release:
  details:
  - ansi-color: 0;38;2;60;110;180
    bug-report-url: https://bugzilla.redhat.com/
    cpe-name: cpe:/o:fedoraproject:fedora:40
    default-hostname: fedora
    documentation-url: https://docs.fedoraproject.org/en-US/fedora/f40/system-administrators-guide/
    home-url: https://fedoraproject.org/
    id: fedora
    logo: fedora-logo-icon
    name: Fedora Linux
    platform-id: platform:f40
    pretty-name: Fedora Linux 40 (Container Image)
    redhat-bugzilla-product: Fedora
    redhat-bugzilla-product-version: '40'
    redhat-support-product: Fedora
    redhat-support-product-version: '40'
    support-end: '2025-05-13'
    support-url: https://ask.fedoraproject.org/
    variant: Container Image
    variant-id: container
    version: 40 (Container Image)
    version-codename: ''
    version-id: '40'
python_version:
  details:
    version: 3.12.5 (main, Aug 23 2024, 00:00:00) [GCC 14.2.1 20240801 (Red Hat 14.2.1-1)]

Note the format here; to view the information of a specific image, use <span>--eei</span> to set which image.

To check whether an image supports <span>ansible-navigator</span>, it is identified by the image label, and images that support <span>ansible-navigator</span> have the label <span>ansible-execution-environment": "true"</span>.

[root@ansible-controller ansible-navigator]# podman image inspect \
    ghcr.io/ansible-community/ansible-community/community-ee-base:2.17.3-1 \
    -f json | jq .[0].Config.Labels
{
"ansible-execution-environment": "true",
"io.buildah.version": "1.23.1",
"license": "MIT",
"name": "fedora",
"org.opencontainers.image.license": "MIT",
"org.opencontainers.image.name": "fedora",
"org.opencontainers.image.url": "https://fedoraproject.org/",
"org.opencontainers.image.vendor": "Fedora Project",
"org.opencontainers.image.version": "40",
"vendor": "Fedora Project",
"version": "40"
}

Ansible-navigator collections

<span>ansible-navigator collections</span> views the available collections within the container.

Option Type Default Value Description
<span>--fmt</span>, <span>--format</span> <span>str</span> <span>yaml</span> Specify the format of standard output, supporting <span>json</span> or <span>yaml</span> formats
# View collections in interactive mode
[root@ansible-controller ansible-navigator]# ansible-navigator \
    --eei quay.io/ansible/awx-ee:24.6.1 -m interactive collections

# View collections in non-interactive mode
[root@ansible-controller ansible-navigator]# ansible-navigator \
    --eei quay.io/ansible/awx-ee:24.6.1 -m stdout collections --fmt json

Ansible-navigator replay

<span>ansible-navigator replay</span> is used to revisit the results of executed Playbook tasks; it has no special options.

# View in interactive mode
[root@ansible-controller ansible-navigator]# ansible-navigator \
    --eei quay.io/ansible/awx-ee:24.6.1 -m interactive \
    replay artifacts/test/test-artifact-2025-05-30T15:55:35.891605+00:00.json

# View in non-interactive mode
[root@ansible-controller ansible-navigator]# ansible-navigator \
    --eei quay.io/ansible/awx-ee:24.6.1 -m stdout \
    replay artifacts/test/test-artifact-2025-05-30T15:55:35.891605+00:00.json

PLAY [Ansible playbook test] ***************************************************

TASK [Gathering Facts] *********************************************************
ok: [worker1]
ok: [master1]

TASK [Print "Hello World!"] ****************************************************
ok: [master1] => {
    "msg": "Hello World!"
}
ok: [worker1] => {
    "msg": "Hello World!"
}

PLAY RECAP *********************************************************************
master1                    : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
worker1                    : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

For information on the location of replay files, refer to the previous section on <span>ansible-navigator run</span>.

Leave a Comment