From charlesreid1

This article covers configuration of Ansible using the Ansible configuration file, ansible.cfg.

Note: any configuration option that can be set in ansible.cfg can also be set/overridden with an environment variable.

Overview

The configuration file, like the hosts file, consists of headings in [brackets] followed by key = value values, one per line.

Example:

ansible.cfg:

[defaults]
inventory = hosts
remote_user = vagrant
private_key_file = ~/.vagrant.d/insecure_private_key
host_key_checking = False

This saves you from having to use the -i flag for inventory and the -u flag for user, and from having to specify the private key in the hosts file.

References

There is a comprehensive reference listing all possible options that can be set in this file here: https://docs.ansible.com/ansible/latest/reference_appendices/config.html

Each configuration option can also be set with an environment variable.


Flags