Ansible-navigator config
<span>ansible-navigator config</span> is used to view Ansible’s configuration files within a container (equivalent to executing the <span>ansible-config</span> command inside the container). The available options are as follows:
| Parameter | Type | Default Value | Description |
<span>-c</span>, <span>--config</span> |
<span>str</span> |
Auto-detect (according to Ansible’s default lookup order) | Specify the path to the <span>ansible.cfg</span> configuration file |
<span>--hc</span>, <span>--help-config</span> |
<span>bool</span> |
No argument means <span>false</span>, with argument means <span>true</span> |
Display help for the <span>ansible-config</span> command (in stdout mode) |
View <span>config</span> help:
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m interactive config --hc
usage: ansible-config [-h] [--version] [-v] {list,dump,view,init} ...
View ansible configuration.
positional arguments:
{list,dump,view,init}
list Print all config options
dump Dump configuration
view View configuration file
init Create initial configuration
optional arguments:
--version show program's version number, config file location, configured module search path, module location, executable location and exit
-h, --help show this help message and exit
-v, --verbose Causes Ansible to print more debug messages. Adding multiple -v will increase the verbosity, the builtin plugins currently evaluate up to -vvvvvv. A reasonable level to
start is -vvv, connection debugging might require -vvvv.
View the configuration of <span>ansible.cfg</span> in interactive mode:
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m interactive config -c ansible.cfg
It seems that the interactive mode can only view configurations.
View configuration in non-interactive mode:
# View help
[root@ansible-controller ansible-navigator]# ansible-navigator config --hc
# View current configuration
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m stdout config view -c ansible.cfg
[defaults]
inventory=./inventory
host_key_checking=False
fact_caching=jsonfile
fact_caching_connection=./cache
Essentially, it is executing the
<span>ansible-config</span>command inside the container. For more details, you can check<span>ansible-config -h</span>. It is not used often; most of the time, it is used to initialize the configuration file.
Ansible-navigator inventory
<span>ansible-navigator inventory</span> is used to execute <span>ansible-inventory</span> within the image.
| Option | Type | Default Value | Description |
<span>--hi</span>, <span>--help-inventory</span> |
<span>bool</span> |
None | Controls whether to display the help information for <span>ansible-inventory</span> in standard output mode. Adding this option means <span>true</span>, not adding means <span>false</span>. |
<span>-i</span>, <span>--inventory</span> |
<span>str</span> |
None | Specify the path to the inventory file or a comma-separated list of hosts. For example:<span>-i inventory.yml</span> or <span>-i host1,host2,</span>. |
<span>--ic</span>, <span>--inventory-column</span> |
<span>str</span> |
None | Specify the host attributes to display in the host list view, can only see variables defined in the host inventory (some magic variables), only effective in TUI mode. |
# View help
[root@ansible-controller ansible-navigator]# ansible-navigator inventory --hi
# Interactive view of the host inventory
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m interactive inventory -i inventory
Title Description
0│Browse groups Explore each inventory group and group members members
1│Browse hosts Explore the inventory with a list of all hosts
# Press 1 to view hosts
Inventory hostname
0│master1
1│worker1
# Interactive view of hosts and display specific variables
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m interactive inventory -i inventory \
--ic inventory_hostname --ic ansible_ssh_host --ic ansible_ssh_user
# Directly view host content
Inventory hostname Inventory hostname Ansible ssh host Ansible ssh user
0│master1 master1 192.168.221.142 ansible
1│worker1 worker1 192.168.221.143 ansible
# Non-interactive view of the host inventory
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m stdout inventory -i inventory \
--list --yaml
all:
children:
k8s:
hosts:
master1:
HOSTNAME: master1.example.com
ansible_ssh_host: 192.168.221.142
ansible_ssh_password: redhat
ansible_ssh_user: ansible
worker1:
HOSTNAME: worker1.example.com
ansible_ssh_host: 192.168.221.143
ansible_ssh_password: redhat
ansible_ssh_user: ansible
Ansible-navigator lint
<span>ansible-navigator lint</span> executes <span>ansible-lint</span> within the container, used to analyze and check for potential issues in Ansible Playbooks, roles, and tasks.
| Option / Parameter Name | Type | Default Value | Description |
<span>--lic</span>, <span>--lint-config</span> |
<span>str</span> |
None | Specify the path to the <span>ansible-lint</span> configuration file (e.g., <span>.ansible-lint</span> or <span>ansible-lint.yml</span>). |
<span>lintables</span> |
<span>path</span> |
None | Path to the files or directories to be checked by <span>ansible-lint</span>, which can be Playbooks, roles, tasks, etc. |
[root@ansible-controller ansible-navigator]# ansible-navigator \
--ee false lint test.yml
ansible-lint 25.4.0 using ansible-core:2.18.6 ansible-compat:25.5.0 ruamel-yaml:0.18.10 ruamel-yaml-clib:0.2.12
name[casing]: All names should start with an uppercase letter.
test.yml:2:9
yaml[trailing-spaces]: Trailing spaces
test.yml:5
name[casing]: All names should start with an uppercase letter.
test.yml:6:11 Task/Handler: debug
yaml[indentation]: Wrong indentation: expected at least 3
test.yml:6
fqcn[action-core]: Use FQCN for builtin module actions (debug).
test.yml:7:5 Use `ansible.builtin.debug` or `ansible.legacy.debug` instead.
yaml[trailing-spaces]: Trailing spaces
test.yml:7
Previously, it was mentioned that
<span>ansible-navigator</span>executes commands inside the container, but it can also be executed directly on the physical machine. Just set<span>--ee false</span>. This setting is used because the image does not include the<span>ansible-lint</span>command; if the image includes the<span>ansible-lint</span>command, it can be run through the container.
Ansible-navigator settings
<span>ansible-navigator settings</span> is used to view and initialize the settings of <span>ansible-navigator</span>. The available options are as follows:
| Option | Type | Default Value | Description |
<span>--se</span>, <span>--effective</span> |
<span>bool</span> |
None | Display all currently effective configurations, including the merged results of default values, CLI parameters, environment variables, and setting files. (Adding this option means <span>true</span>) |
<span>--gs</span>, <span>--sample</span> |
<span>bool</span> |
None | Generate a sample settings file that can be modified. (Adding this option means <span>true</span>) |
<span>--ss</span>, <span>--schema</span> |
<span>str</span> |
<span>json</span> |
Generate the schema structure of the settings file (currently only supports <span>json</span> format, compliant with JSON Schema draft-07 standard). |
<span>--so</span>, <span>--sources</span> |
<span>bool</span> |
None | Display the source of each setting (whether it is a default value, environment variable, command line parameter, or settings file). (Adding this option means <span>true</span>) |
# Interactive view of settings
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m interactive settings
# Non-interactive view of settings
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m stdout settings --se
# Initialize a configuration
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m stdout settings --gs > ansible-navigator
[root@ansible-controller ansible-navigator]# mv ansible-navigator ansible-navigator.yaml
When initializing the configuration, it does not directly import as the default configuration into
<span>ansible-navigator.yaml</span>, because redirecting content to a file will first create an empty file<span>ansible-navigator.yaml</span>, and since the content is empty, it will cause the command to fail. Therefore, it is necessary to first output the default configuration to a file with a different name and then rename it to<span>ansible-navigator.yaml</span>.
[root@ansible-controller test]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m stdout --ll debug settings --gs > ansible-navigator.yaml
Warning: Issues were found while applying the settings.
Hint: Command provided: '--eei quay.io/ansible/awx-ee:24.6.1 -m stdout --ll
debug settings --gs'
Error: Settings file found /tmp/test/ansible-navigator.yaml, but failed to
load it.
error was: 'Settings file cannot be empty.'
Hint: Try checking the settings file '/tmp/test/ansible-navigator.yaml'and
ensure it is properly formatted
Note: Configuration failed, using default log file location.
(/tmp/test/ansible-navigator.log) Log level set to debug
Hint: Review the hints and log file to see what went wrong.
This section only introduces how to use this command; detailed information about the configuration will be explained separately later.
Ansible-navigator builder
<span>ansible-navigator builder</span> is used to build Ansible execution environment images.
| Option | Parameter Type | Default Value | Description |
<span>--hb</span>, <span>--help-builder</span> |
<span>bool</span> |
None | Whether to display the help information for <span>ansible-builder</span> in standard output mode, with values of <span>true</span> or <span>false</span>. |
<span>--bwd</span>, <span>--workdir</span> |
<span>str</span> |
Current directory | Specify the directory path containing the <span>ansible-builder</span> manifest file (e.g., <span>execution-environment.yml</span>). |
[root@ansible-controller ansible-navigator]# ansible-navigator \
--eei quay.io/ansible/awx-ee:24.6.1 -m stdout \
builder --workdir /tmp/test/ build --tag test:v1 -vvv
In addition to this, the
<span>ansible-builder</span>command can also be used for building.Details on how to build Ansible execution environment images will be discussed later.