Ansible Configuration Files¶
ansible.cfg¶
This tells Ansible where to find things and how to behave. Place at ~/ansible/ansible.cfg.
The core of it:
[defaults]
inventory = inventory/hosts.ini
remote_user = username
private_key_file = ~/.ssh/ansible
# ...
[privilege_escalation]
become = True
# ...
The complete file is in the worked example: Base Configuration → ansible.cfg.
What each setting does:
inventory: Default inventory file so you don't have to pass-ievery time.remote_user: SSH user on all managed nodes.private_key_file: The Ansible SSH key you generated.roles_path: Where to find roles.host_key_checking = False: Don't prompt on first SSH connection. Safe on a local VLAN.retry_files_enabled = False: Don't create.retryfiles on failure (they clutter the directory).callback_result_format = yaml: More readable output format (YAML results from the built-in default callback; the oldstdout_callback = yamlplugin was removed in community.general 12).become = True: Use sudo by default (most tasks need root).become_ask_pass = False: Assumes username has passwordless sudo. If not, set this to True or configure sudoers.vault_password_file = .vault_pass: Decrypts the vault automatically (see Vault).
Important: username needs passwordless sudo on all managed nodes. Fresh Debian minimal doesn't ship sudo, so this is a manual step before the first run: see Install & project setup → SSH key setup or Base Configuration → Pre-Ansible setup.
Ref: https://docs.ansible.com/projects/ansible/latest/reference_appendices/config.html