Viewing Configuration Options
If you want to find out what options are available in the configuration file, use the ansible-config list command. It will display an exhaustive list of the available configuration options and their default settings. This list may vary depending on the version of Ansible that you have installed and whether you have any additional Ansible plugins on your control node.
Each option displayed by ansible-config list will have a number of key-value pairs associated with it. These key-value pairs provide information on how that option works. For example, the option ACTION_WARNINGS displays the following key-value pairs:
KEY | VALUE | PURPOSE |
---|---|---|
description | [By default Ansible will issue a warning when received from a task action (module or action plugin). These warnings can be silenced by adjusting this setting to False.] | Describes what this configuration option is for. |
type | boolean | What the type is for the option: boolean means true-false value. |
default | true | The default value for this option. |
version_added | 2.5 | The version of Ansible that added this option, for backward compatibility. |
ini | { key: action_warnings, section: defaults } | Which section of the INI-like inventory file contains this option, and the name of the option in the configuration file (action_warnings, in the defaults section). |
env | ANSIBLE_ACTION_WARNINGS | If this environment variable is set, it will override any setting of the option made in the configuration file. |
Determining Modified Configuration Options
When working with configuration files, you might want to find out which options have been set to values which are different from the built-in defaults. You can do this by running the ansible-config dump -v -\-only-changed command. The -v option displays the location of the ansible.cfg file used when processing the command. The ansible-config command follows the same order of precedence mentioned previously for the ansible command. Output will vary depending on the location of the ansible.cfg file and which directory the ansible-config command is ran from.
In the following example, there is a single ansible configuration file located at /etc/ansible/ansible.cfg. The ansible-config command is first ran from student’s home directory, then from a working directory with the same results:
[user@controlnode ~]$ ansible-config dump -v -\-only-changed Using /etc/ansible/ansible.cfg as config file DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles', u'/usr/ share/ansible/roles']
[user@controlnode ~]$ cd /home/student/workingdirectory [user@controlnode workingdirectory]$ ansible-config dump -v -\-only-changed Using /etc/ansible/ansible.cfg as config file DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles', u'/usr/ share/ansible/roles']
However, if you have a custom ansible.cfg file in your working directory, the same command will display information based on where it is ran from and the relative ansible.cfg file.
[user@controlnode ~]$ ansible-config dump -v -\-only-changed Using /etc/ansible/ansible.cfg as config file DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles', u'/usr/share/ansible/roles']
[user@controlnode ~]$ cd /home/student/workingdirectory [user@controlnode workingdirectory]$ cat ansible.cfg [defaults] inventory = ./inventory remote_user = devops
[user@controlnode workingdirectory]$ ansible-config dump -v -\-only-changed Using /home/student/workingdirectory/ansible.cfg as config file DEFAULT_HOST_LIST(/home/student/workingdirectory/ansible.cfg) = [u'/home/student/workingdirectory/inventory'] DEFAULT_REMOTE_USER(/home/student/workingdirectory/ansible.cfg) = devops