ansible.cfg is Ansible’s configuration file. It sets defaults for how Ansible behaves, such as the inventory path, remote user, privilege escalation, SSH settings, roles and Collections paths, and number of parallel forks. Settings in it apply to every Ansible command run with that file.
Ansible uses the first file it finds, in this order:
- The path in the
ANSIBLE_CONFIGenvironment variable. ansible.cfgin the current directory.~/.ansible.cfgin the home directory./etc/ansible/ansible.cfg.
ansible.cfg example
[defaults]
inventory = ./inventory.yml
remote_user = automation
forks = 20
roles_path = ./roles
Generate a fully commented file with ansible-config init --disabled > ansible.cfg, and see active settings with ansible-config dump --only-changed.