Ansible Configuration from Beginner to Abandonment (Part 18)

Ansible-navigator Configuration

You can obtain the default configuration by running <span>ansible-navigator --eei quay.io/ansible/awx-ee:24.6.1 settings --gs</span>. The <span>ansible-navigator</span> looks for the configuration files <span>ansible-navigator.yaml</span> or <span>ansible-navigator.yml</span>. Here is a default configuration:

---
ansible-navigator:
#   ansible:
#     config:
#       # Help options for ansible-config command in stdout mode
#       help: False
#       # Specify the path to the ansible configuration file
#       path: ./ansible.cfg
#     # Extra parameters passed to the underlying ansible command (e.g.
#     # ansible-playbook, ansible-doc, etc)
#     cmdline: "--forks 15"
#     doc:
#       # Help options for ansible-doc command in stdout mode
#       help: False
#       plugin:
#         # Specify the plugin name
#         name: debug
#         # Specify the plugin type, 'become', 'cache', 'callback', 'cliconf',
#         # 'connection', 'filter', 'httpapi', 'inventory', 'keyword', 'lookup',
#         # 'module', 'netconf', 'role', 'shell', 'strategy', 'test' or 'vars'
#         type: module
#     inventory:
#       # Help options for ansible-inventory command in stdout mode
#       help: True
#       # Specify an inventory file path or comma separated host list
#       entries:
#         - host1,
#         - router1,router2
#         - inventory.yml
#     playbook:
#       # Help options for ansible-playbook command in stdout mode
#       help: False
#       # Specify the playbook name
#       path: site.yml
#   ansible-builder:
#     # Help options for ansible-builder command in stdout mode
#     help: False
#     # Specify the path that contains ansible-builder manifest files
#     workdir: /tmp/
#   ansible-lint:
#     # Specify the path to the ansible-lint configuration file
#     config: ~/lint-config.yml
#     # Path to files on which to run ansible-lint
#     lintables: ~/myproject/
#   ansible-runner:
#     # The directory path to store artifacts generated by ansible-runner
#     artifact-dir: ./runner-artifacts
#     # Keep ansible-runner artifact directories, for last n runs, if set to 0
#     # artifact directories won't be deleted
#     rotate-artifacts-count: 10
#     # The timeout value after which ansible-runner will forcefully stop the
#     # execution
#     timeout: 300
#     # Write ansible-runner job_events in the artifact directory
#     job-events: True
#   # Subcommands
#   app: welcome
#   # The path to collection doc cache
#   collection-doc-cache-path: $HOME/.cache/ansible-navigator/collection_doc_cache.db
#   color:
#     # Enable the use of color for mode interactive and stdout
#     enable: True
#     # Enable or disable terminal color changing support with OSC 4
#     osc4: True
#   editor:
#     # Specify the editor command
#     command: vim_from_setting
#     # Specify if the editor is console based
#     console: False
#   # Enable prompts for password and in playbooks. This will set mode to
#   # stdout and disable playbook artifact creation
#   enable-prompts: False
#   exec:
#     # Specify the exec command should be run in a shell
#     shell: True
#     # Specify the command to run within the execution environment
#     command: /bin/bash
#   execution-environment:
#     # Specify the container engine (auto=podman then docker)
#     container-engine: auto
#     # Extra parameters passed to the container engine command
#     container-options:
#       - "--net=host"
#     # Enable or disable the use of an execution environment
#     enabled: True
#     environment-variables:
#       # Specify an existing environment variable to be passed through to and
#       # set within the execution environment (--penv MY_VAR)
#       pass:
#         - ONE
#         - TWO
#         - THREE
#       # Specify an environment variable and a value to be set within the
#       # execution environment (--senv MY_VAR=42)
#       set:
#         KEY1: VALUE1
#         KEY2: VALUE2
#         KEY3: VALUE3
#     # Specify the name of the execution environment image
#     image: quay.io/organization/custom-ee:latest
#     pull:
#       # Specify any additional parameters that should be added to the pull
#       # command when pulling an execution environment from a container
#       # registry. e.g. --pa='--tls-verify=false'
#       arguments:
#         - "--tls-verify=false"
#       # Specify the image pull policy always:Always pull the image,
#       # missing:Pull if not locally available, never:Never pull the image,
#       # tag:if the image tag is 'latest', always pull the image, otherwise
#       # pull if not locally available
#       policy: tag
#     # Specify volume to be bind mounted within an execution environment
#     # (--eev /home/user/test:/home/user/test:Z)
#     volume-mounts:
#       - src: "/tmp/directory"
#         dest: "/tmp/directory"
#         options: "Z"
#   # Specify the format for stdout output.
#   format: json
#   images:
#     # Provide detailed information about the selected execution environment
#     # image
#     details:
#       - ansible_collections
#       - ansible_version
#   # Specify a host attribute to show in the inventory view
#   inventory-columns:
#     - ansible_network_os
#     - ansible_network_cli_ssh_type
#     - ansible_connection
  logging:
#     # Specify the ansible-navigator log level
    level: debug
#     # Specify if log messages should be appended to an existing log file,
#     # otherwise a new log file will be created per session
    append: False
#     # Specify the full path for the ansible-navigator log file
#     file: $PWD/ansible-navigator.log
#   # Specify the user-interface mode
#   mode: interactive
#   playbook-artifact:
#     # Enable or disable the creation of artifacts for completed playbooks.
#     # Note: not compatible with '--mode stdout' when playbooks require user
#     # input
#     enable: True
#     # Specify the path for the playbook artifact to replay
#     replay: /tmp/test_artifact.json
#     # Specify the name for artifacts created from completed playbooks. The
#     # following placeholders are available: {playbook_dir}, {playbook_name},
#     # {playbook_status}, and {time_stamp}
#     save-as: "{playbook_dir}/{playbook_name}-artifact-{time_stamp}.json"
#   settings:
#     # Show the effective settings. Defaults, CLI parameters, environment
#     # variables, and the settings file will be combined
#     effective: False
#     # Generate a sample settings file
#     sample: False
#     # Generate a schema for the settings file ('json'= draft-07 JSON Schema)
#     schema: json
#     # Show the source of each current settings entry
#     sources: False
#   # Specify the IANA time zone to use or 'local' to use the system time
#   # zone
#   time-zone: UTC

<span>ansible-navigator:</span> is the top-level key for the <span>ansible-navigator</span> configuration, which has 19 sub-items:

ansible-navigator:
  ansible:                    # Configuration related to the native command
  ansible-builder:            # EE image build configuration
  ansible-lint:               # Playbook lint check configuration
  ansible-runner:             # Runner executor parameters
  app:                        # Initial subcommands (e.g., welcome, run, settings, etc.)
  collection-doc-cache-path: # Collection document cache path
  color:                      # TUI/terminal color settings
  editor:                     # Editor settings
  enable-prompts:            # Whether to allow interactive input
  exec:                       # Settings for executing commands in EE
  execution-environment:     # EE container related configuration
  format:                    # stdout output format
  images:                    # EE image detailed information display settings
  inventory-columns:         # Additional columns in the host view of TUI mode
  logging:                   # Logging settings
  mode:                      # Interface mode (interactive or stdout)
  playbook-artifact:         # Playbook execution result artifact save configuration
  settings:                  # Configuration file related settings
  time-zone:                 # Time zone settings

Although there is a lot of content written below, most of it consists of options for the previous subcommands, many of which should be self-explanatory.

  • <span>ansible:</span> field configuration
    Field Path Type Default Value/Example Function Description
    <span>ansible-navigator.ansible.config.help</span> <span>bool</span> <span>false</span> Whether to display help information for <span>ansible-config</span> in stdout mode
    <span>ansible-navigator.ansible.config.path</span> <span>string</span> <span>./ansible.cfg</span> Specify the path to the Ansible configuration file
    <span>ansible-navigator.ansible.cmdline</span> <span>string</span> <span>"--forks 15"</span> Pass additional parameters to the underlying ansible command (e.g., controlling concurrency)
    <span>ansible-navigator.ansible.doc.help</span> <span>bool</span> <span>false</span> Whether to display help information for <span>ansible-doc</span> in stdout mode
    <span>ansible-navigator.ansible.doc.plugin.name</span> <span>string</span> <span>"debug"</span> The name of the plugin to query documentation for
    <span>ansible-navigator.ansible.doc.plugin.type</span> <span>string</span> <span>"module"</span> Plugin type, options include: <span>module</span>, <span>lookup</span>, <span>strategy</span>, <span>role</span>, etc.
    <span>ansible-navigator.ansible.inventory.help</span> <span>bool</span> <span>true</span> Whether to display help information for <span>ansible-inventory</span> in stdout mode
    <span>ansible-navigator.ansible.inventory.entries</span> <span>list[string]</span> <span>["host1,", "router1,router2", "inventory.yml"]</span> Specify static or dynamic inventory file paths or inline host strings
    <span>ansible-navigator.ansible.playbook.help</span> <span>bool</span> <span>false</span> Whether to display help information for <span>ansible-playbook</span> in stdout mode
    <span>ansible-navigator.ansible.playbook.path</span> <span>string</span> <span>"site.yml"</span> Specify the path to the default playbook file to execute
  • <span>ansible-builder:</span> field configuration:
    Field Path Type Default Value/Example Function Description
    <span>ansible-navigator.ansible-builder.help</span> <span>bool</span> <span>false</span> Whether to display help information for <span>ansible-builder</span> in stdout mode
    <span>ansible-navigator.ansible-builder.workdir</span> <span>string</span> <span>/tmp/</span> Specify the path to the working directory containing build manifest files (e.g., <span>execution-environment.yml</span>)
  • <span>ansible-lint:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.ansible-lint.config</span> <span>string</span> <span>~/lint-config.yml</span> Specify the path to the configuration file used by <span>ansible-lint</span> (e.g., <span>.ansible-lint</span>)
    <span>ansible-navigator.ansible-lint.lintables</span> <span>string</span> <span>~/myproject/</span> Specify the target files or directories (can be playbook/role) on which to run <span>ansible-lint</span>
  • <span>ansible-runner:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.ansible-runner.artifact-dir</span> <span>string</span> <span>./runner-artifacts</span> Specify the directory to save the artifacts of the execution results
    <span>ansible-navigator.ansible-runner.rotate-artifacts-count</span> <span>int</span> <span>10</span> Number of recent artifacts to keep, automatically deleted if exceeded; set to <span>0</span> to indicate no deletion
    <span>ansible-navigator.ansible-runner.timeout</span> <span>int</span> <span>300</span> Execution timeout (in seconds), forcefully abort execution after timeout
    <span>ansible-navigator.ansible-runner.job-events</span> <span>bool</span> <span>true</span> Whether to write events to the artifact (detailed task event tracking)
  • <span>app:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.app</span> <span>string</span> <span>welcome</span> The default subcommand interface to enter at startup, options include <span>welcome</span>, <span>run</span>, <span>doc</span>, <span>config</span>, <span>inventory</span>, <span>settings</span>, etc.
  • <span>collection-doc-cache-path:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.collection-doc-cache-path</span> <span>string</span> <span>$HOME/.cache/ansible-navigator/collection_doc_cache.db</span> Specify the location of the collection plugin document cache database to improve the loading efficiency of <span>ansible-navigator doc</span>.
  • <span>color:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.color.enable</span> <span>bool</span> <span>true</span> Whether to enable color output (applicable to <span>interactive</span> mode and <span>stdout</span> mode)
    <span>ansible-navigator.color.osc4</span> <span>bool</span> <span>true</span> Whether to enable OSC 4 control codes for terminal color changes (supported by some terminals)
  • <span>editor:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.editor.command</span> <span>string</span> <span>vim_from_setting</span> Specify the editor command to call, such as <span>vim</span>, <span>nano</span>, <span>code</span>, <span>nvim</span>, etc.
    <span>ansible-navigator.editor.console</span> <span>bool</span> <span>false</span> Indicate whether the editor runs within the console (<span>true</span> indicates console editors like <span>vim</span>, <span>nano</span>)
  • <span>enable-prompts:</span> field configuration:
    Field Path Type Example Value Default Value Function Description
    <span>ansible-navigator.enable-prompts</span> <span>bool</span> <span>false</span> <span>false</span> Whether to enable interactive prompts (e.g., sudo password, variable input, ask-pass, etc.) Enabling this will force the use of <span>stdout</span> mode and disable playbook artifact generation
  • <span>exec:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.exec.shell</span> <span>bool</span> <span>true</span> Whether to run commands in the shell (i.e., <span>/bin/sh -c "your command"</span>)
    <span>ansible-navigator.exec.command</span> <span>string</span> <span>/bin/bash</span> The default command to execute, usually an interactive shell, such as <span>/bin/bash</span> or <span>/bin/sh</span>
  • <span>execution-environment:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.execution-environment.container-engine</span> <span>string</span> <span>auto</span> Container runtime selection: <span>auto</span> (prefer podman), or <span>docker</span>/<span>podman</span>
    <span>ansible-navigator.execution-environment.container-options</span> <span>list</span> <span>["--net=host"]</span> Additional parameters passed to the container engine
    <span>ansible-navigator.execution-environment.enabled</span> <span>bool</span> <span>true</span> Whether to enable the execution environment (EE); set to false to run Ansible directly on the host
    <span>ansible-navigator.execution-environment.environment-variables.pass</span> <span>list</span> <span>[ONE, TWO, THREE]</span> Pass current host environment variables to the EE container (equivalent to <span>--penv</span>)
    <span>ansible-navigator.execution-environment.environment-variables.set</span> <span>dict</span> <span>{KEY1: VALUE1, KEY2: VALUE2}</span> Set new environment variables in the EE container (equivalent to <span>--senv</span>)
    <span>ansible-navigator.execution-environment.image</span> <span>string</span> <span>quay.io/organization/custom-ee:latest</span> Specify the execution environment container image to use
    <span>ansible-navigator.execution-environment.pull.arguments</span> <span>list</span> <span>["--tls-verify=false"]</span> Specify parameters to use when pulling the container image
    <span>ansible-navigator.execution-environment.pull.policy</span> <span>string</span> <span>tag</span> Image pull policy: <span>always</span>, <span>missing</span>, <span>never</span>, <span>tag</span>
    <span>ansible-navigator.execution-environment.volume-mounts</span> <span>list[dict]</span> <span>{src: ..., dest: ..., options: ...}</span> Specify the host path to bind mount (equivalent to <span>--eev</span>)
  • <span>format:</span> field configuration:
    Field Path Type Example Value Default Value Function Description
    <span>ansible-navigator.format</span> <span>string</span> <span>json</span> <span>yaml</span> Specify the output format in <span>--mode stdout</span> mode, supports <span>yaml</span> and <span>json</span>
  • <span>images:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.images.details</span> <span>list[string]</span> <span>["ansible_collections", "ansible_version"]</span> Specify the fields of detailed information to display when executing the <span>images</span> subcommand
  • <span>inventory-columns:</span> field configuration:
    Field Path Type Example Value List Function Description
    <span>ansible-navigator.inventory-columns</span> <span>list[string]</span> <span>["ansible_network_os", "ansible_network_cli_ssh_type", "ansible_connection"]</span> Specify additional host attribute columns to display in the inventory view in interactive mode (TUI)
  • <span>logging:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.logging.level</span> <span>string</span> <span>debug</span> Set the log detail level, supports: <span>critical</span>, <span>error</span>, <span>warning</span>, <span>info</span>, <span>debug</span>, <span>notset</span>
    <span>ansible-navigator.logging.append</span> <span>bool</span> <span>false</span> Whether to append log messages to an existing file, otherwise a new log file will be created per session
    <span>ansible-navigator.logging.file</span> <span>string</span> <span>$PWD/ansible-navigator.log</span> Set the full path for the ansible-navigator log file, variables like <span>$PWD</span>, <span>$HOME</span> can be used
  • <span>mode:</span> field configuration:
    Field Path Type Example Value Default Value Function Description
    <span>ansible-navigator.mode</span> <span>string</span> <span>interactive</span> <span>interactive</span> Set the running interface mode of ansible-navigator, options include: <span>interactive</span> or <span>stdout</span>
  • <span>playbook-artifact:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.playbook-artifact.enable</span> <span>bool</span> <span>true</span> Whether to enable artifact file generation after playbook execution
    <span>ansible-navigator.playbook-artifact.replay</span> <span>string</span> <span>/tmp/test_artifact.json</span> Specify the path for replaying (replaying) previous execution results’ artifacts
    <span>ansible-navigator.playbook-artifact.save-as</span> <span>string</span> <span>"./artifacts/{playbook_name}/{playbook_name}-artifact-{time_stamp}.json"</span> Specify the path template for saving artifact files, supports variable placeholders
  • <span>settings:</span> field configuration:
    Field Path Type Example Value Function Description
    <span>ansible-navigator.settings.effective</span> <span>bool</span> <span>false</span> Whether to display all effective settings (including default values, CLI parameters, environment variables, configuration files), equivalent to <span>--se</span>
    <span>ansible-navigator.settings.sample</span> <span>bool</span> <span>false</span> Whether to generate a complete sample configuration file (all fields have comments), equivalent to <span>--gs</span>
    <span>ansible-navigator.settings.schema</span> <span>string</span> <span>json</span> Output format for the configuration schema, only supports <span>json</span> (compliant with draft-07 JSON Schema standard), equivalent to <span>--ss</span>
    <span>ansible-navigator.settings.sources</span> <span>bool</span> <span>false</span> Whether to display the source of each configuration item (e.g., default, env, cli, settings file), equivalent to <span>--so</span>
  • <span>time-zone:</span> field configuration:
    Field Path Type Example Value Default Value Function Description
    <span>ansible-navigator.time-zone</span> <span>string</span> <span>UTC</span> <span>UTC</span> Specify the time zone used for timestamps (based on the IANA Time Zone Database)

This is configured as needed. If the previous commands have been tested, this configuration file will be easy to understand.

Here is a configuration currently in use:

---
ansible-navigator:
  ansible-runner:
    artifact-dir: ./runner-artifacts
    rotate-artifacts-count: 5
    timeout: 300
    job-events: True
  app: welcome
  collection-doc-cache-path: $HOME/.cache/ansible-navigator/collection_doc_cache.db
  color:
    enable: True
    osc4: True
  enable-prompts: False
  exec:
    shell: False
    #command: /bin/bash -c
  execution-environment:
    container-engine: auto
    container-options:
      - "--net=host"
    enabled: True
    image: quay.io/ansible/awx-ee:24.6.1
    pull:
      arguments:
        - "--tls-verify=false"
      policy: tag
  format: json
  logging:
    level: debug
    append: False
    file: ./artifacts/ansible-navigator.log
  mode: stdout
  playbook-artifact:
    enable: True
    save-as: "./artifacts/{playbook_name}/{playbook_name}-artifact-{time_stamp}.json"
  settings:
    effective: True
    sources: True
  time-zone: UTC

Leave a Comment