Describe where automation content navigator configuration files might be located and edit them to apply changes to default settings.
You can create a configuration file (or settings file) for ansible-navigator to override the default values of its configuration settings.
A configuration file is useful, for example, if you want to use a different automation execution environment from the default one, and you do not want to enter the correct --eei option every time that you use the ansible-navigator command.
The following details apply to settings files:
The settings file can be in JSON or YAML format.
For settings in JSON format, the extension must be .json.
For settings in YAML format, the extension must be .yml or .yaml.
This course focuses on the YAML-formatted configuration file.
Automation content navigator looks for a settings file in the following order and uses the first file that it finds:
If the ANSIBLE_NAVIGATOR_CONFIG environment variable is set, then use the configuration file at the location the variable specifies.
An ansible-navigator.yml file in your current Ansible project directory.
A ~/.ansible-navigator.yml file (in your home directory).
Notice that it has a "dot" at the start of its file name.
Each project can have its own automation content navigator settings file. Common configuration parameters can be the names of automation execution environment images required for the project, Ansible configuration parameters such as forks, log levels, artifact creation, and so on.
The project directory and home directory can only contain one settings file each.
If there is an ansible-navigator.yml file and an ansible-navigator.yaml or ansible-navigator.json file in the same directory, it results in an error.
You can use the ansible-navigator settings command to generate settings files.
You can use the --sample option to output a sample ansible-navigator configuration file in YAML format. You can use the --effective option instead, to output a configuration file that matches the current effective configuration for ansible-navigator. In either case, you can redirect the output of the command into a file to save it, edit it, and use it.
The --sample option generates output where most lines begin with a number sign (#), indicating that they are commented out.
This output also contains comments that describe the settings.
Many comments include samples and display valid setting values.
If you want to use a commented-out line, then to preserve the correct indentation of the YAML file, you must remove the number sign at the beginning of the line and one blank space.
Removing the additional space conforms to the best practice of using two spaces for indentation and ensures that the uncommented lines match the existing indentation of the logging top-level setting.
The --effective option generates more condensed output and does not include any comments.
Many command options, such as the --eei and --pp options are configured in the output.
When running this command, the mode key always has a value of stdout.
If you do not need this value, then you can change the value after generating the sample file.
You can delete any of the lines that you do not want to explicitly configure, but if you remove a parent key, then you must remove all its child keys.
Because the command correctly indents all the output, this method generates a working configuration that you can immediately use.
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.
Instead, redirect the command output to a file in a different directory, such as to the /tmp/ansible-navigator.yml file, or to a file with a different name in the current directory, such as sample.yml.
After the command completes, you can copy or move the generated file to the desired directory with the correct name.
[user@host ~]$ansible-navigator settings --effective --pp missing \--eei ee-supported-rhel8 > /tmp/ansible-navigator.yml
The generated file starts with an ansible-navigator key, which contains subkeys representing the top-level configuration categories and settings.
Top-level settings include ansible for Ansible-specific settings, and execution-environment for the automation execution environment settings that ansible-navigator uses.
Like automation content navigator settings, Ansible configuration settings can be defined in multiple places.
You can define Ansible configuration settings in an ansible.cfg file, in a ~/.ansible.cfg file, or in the /etc/ansible/ansible.cfg file.
Although ansible.cfg files can contain several settings, the files almost always define a path to an inventory source.
For example:
[defaults] inventory = ./inventory
If you only intend to define an inventory source in an ansible.cfg file, then rather than creating that file, you can add inventory entries in the automation content navigator configuration file.
The following example shows how to define inventory sources (or entries) in the ansible key:
---
ansible-navigator:
ansible:
inventory:
entries:
- ./inventoryIf you need to place additional settings in an ansible.cfg file, such as settings for roles or Ansible Content Collections, then you might define the inventory in the ansible.cfg file and not in the ansible-navigator.yml file.
Tools that are included with the ansible-core package use the ansible.cfg file and not the ansible-navigator.yml file.
If an ansible.cfg file and an ansible-navigator.yml file define different inventories, then the ansible-navigator command uses the inventories defined in the ansible-navigator.yml file.
Use the execution-environment key to set default values for a number of the options that ansible-navigator accepts to control automation execution environments.
image
Specifies the container image to use for the automation execution environment, and sets the default for the --execution-environment-image (or --eei) option.
pull
Specifies when and how to pull the container image.
Configuring the policy key is equivalent to using the --pull-policy (or --pp) option.
You can also pass additional arguments, such as disabling TLS verification.
For example, consider the following ansible-navigator command:
[user@host ~]$ansible-navigator run site.yml --pp missing \--eei registry.redhat.io/ansible-automation-platform-23/ee-29-rhel8
You can eliminate the --pp and --eei options if you create an ansible-navigator.yml file, which contains the following content, in the same directory as the site.yml file:
---
ansible-navigator:
execution-environment:
image: registry.redhat.io/ansible-automation-platform-23/ee-29-rhel8:latest
pull:
policy: missingThe mode key takes the same options as the --mode (or -m) option, and defaults to interactive mode.
If you prefer to work in stdout mode, you can specify this with an ansible-navigator.yml file that has the following content:
--- ansible-navigator: mode: stdout
With this configuration, you need to specify the -m interactive option explicitly if you want to run in interactive mode.
The basic design of ansible-navigator assumes that you cannot provide interactive input to the playbook while it is running.
This makes sense because that is also true when you run a playbook in automation controller.
Automation content navigator also records playbook artifact files for each run of the playbook.
These files record information about the playbook run and can be used to review the results of the run when it completes, reviewed to troubleshoot issues, or kept for compliance purposes.
You can review the contents of these files with the ansible-navigator replay command.
However, the contents of these files might contain sensitive information about the playbook run, especially if you are providing authentication-related input to the playbook.filename
If you often run playbooks with interactive password prompts or playbooks that use modules that prompt you for input, you can disable the generation of playbook artifacts with a configuration file such as the following example.
---
ansible-navigator:
playbook-artifact:
enable: falseYou can also temporarily disable playbook artifacts by running the ansible-navigator run command with the --pae false option.