Skip to content

ansible.cfg Cheat Sheet

Search Order (Highest to Lowest)

  1. ANSIBLE_CONFIG env var
  2. ./ansible.cfg
  3. ~/.ansible.cfg
  4. /etc/ansible/ansible.cfg

CLI flag > environment variable (ANSIBLE_*) > ansible.cfg value > built-in default.

A Practical Starting Point

[defaults]
inventory = inventories/production/hosts.ini
remote_user = deploy
host_key_checking = True
forks = 20
retry_files_enabled = False

[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=60s

[privilege_escalation]
become = True
become_method = sudo
ansible-config dump --only-changed   # see what's actually in effect

Full explanation: ansible.cfg · Performance