Bookmark this page

Configuring Automation Content Navigator

Objectives

  • Change configuration settings for automation content navigator with its configuration file, and determine where the configuration file is located.

Format of the Settings File

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 you run the ansible-navigator command.

  • 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.

Locating the Settings 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 names of automation execution environment images required for the project, Ansible configuration parameters such as forks, log levels, artifact creation, and so on.

Important

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.

Selecting a Settings File to Use

If you have an ansible-navigator.yml file in your Ansible project directory, it is stored in version control with the rest of your project, and overrides any configuration file in the user's home directory. This also means that other users of that project use that same configuration file.

If you have a ~/.ansible-navigator.yml file, it is used only if there is no other configuration file available. You can use it to specify default settings to use if the Ansible project you are working with has no preferred configuration settings.

You should only specify an automation content navigator configuration file with the ANSIBLE_NAVIGATOR_CONFIG environment variable if you want to override all other configuration files.

Generating a Settings File

You can use the ansible-navigator settings command to generate settings files. If you run that command with the --sample option, then the command outputs a sample ansible-navigator configuration file in YAML format. If you run that command with the --effective option instead, then the command outputs a configuration file that matches the current effective configuration for ansible-navigator. In either case, you could 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 options that you can pass to the command, 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.

Important

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.

---
ansible-navigator:
...output omitted...
  execution-environment:
    container-engine: podman
    enabled: true
    image: ee-supported-rhel8:latest
    pull:
      policy: missing
...output omitted...

Setting a Default Automation Execution Environment

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 the equivalent to using the --pull-policy (or --pp) option. You can also pass additional arguments, such as disabling TLS verification.

  • enabled specifies whether to use an automation execution environment or not and defaults to True.

As an example, consider the following ansible-navigator command:

[user@host ~]$ ansible-navigator run site.yml --eei ee-29-rhel8 --pp always

You can eliminate the --eei and --pp 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: ee-29-rhel8:latest
    pull:
      policy: always

That would convert the preceding command to the following:

[user@host ~]$ ansible-navigator run site.yml

Specify the other advanced options to adjust the exact behavior of the automation execution environment.

Setting the Default Mode to Standard Output

The mode key takes the same options as the --mode (-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.

Disabling Playbook Artifacts

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 filename 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.

If you frequently 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. Alternatively, you can temporarily disable playbook artifacts by running the ansible-navigator run command with the --pae false option.

---
ansible-navigator:
  playbook-artifact:
    enable: false

Overview of an Example Settings File

The following ansible-navigator.yml file configures some common settings:

---
ansible-navigator:
  ansible:
    config:
      path: ./ansible.cfg

  editor: 1
    command: /bin/emacs

  execution-environment: 2
    image: ee-supported-rhel8:latest
    pull:
      policy: missing

  playbook-artifact: 3
    enable: false

1

You can configure ansible-navigator to use the text editor of your choice.

2

By default, the ansible-navigator command looks for the registry.redhat.io/ansible-automation-platform-22/ee-supported-rhel8:latest image. You can configure it to use a specific automation execution environment by defining the execution-environment section in the settings file.

3

To enable the ansible-navigator command to prompt for passwords, you can disable playbook artifacts.

More information about the available options and how to use them is available in the references at the end of this section.

Revision: do374-2.2-82dc0d7