ansible.cfg

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:

  1. The path in the ANSIBLE_CONFIG environment variable.
  2. ansible.cfg in the current directory.
  3. ~/.ansible.cfg in the home directory.
  4. /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.