Ansible Configuration
Ansible configuration controls how commands behave, where inventory is loaded from, and how connections are handled. A project-level ansible.cfg is usually the cleanest approach.
Configuration Precedence
When the same setting appears in multiple places, Ansible generally uses this order:
- Command-line options
- Environment variables
ansible.cfg- Built-in defaults
Common Config File Locations
Ansible looks for configuration in this order:
ANSIBLE_CONFIG./ansible.cfg~/.ansible.cfg/etc/ansible/ansible.cfg
Recommended Project Config
Create ansible.cfg in the project root so the team shares the same behavior.
Example:
[defaults]
inventory = inventory.ini
host_key_checking = False
retry_files_enabled = False
Useful Settings
inventory: Default inventory filehost_key_checking: Useful in labs, but review carefully for productionretry_files_enabled: Disables retry file cluttertimeout: Controls SSH timeout behavior
Quick Check
ansible-config dump --only-changed
ansible --version