Quiz Entry - updated: 2026.10.30
If both ~/.ansible.cfg and ./ansible.cfg exist and each sets different keys, which settings apply?
Only those in ./ansible.cfg. Ansible does not merge configuration files: it uses settings from the first file it finds and ignores all others completely.
This surprises people who expect cascading config like CSS or Git, where a project file only overrides the keys it mentions. In Ansible, a project ansible.cfg that sets only inventory = ./inventory means that your personal remote_user from ~/.ansible.cfg is gone for commands run in that directory. Any key the winning file doesn't set falls back to Ansible's built-in default, not to the next file in the list.
Practical consequences:
- A project's
ansible.cfgshould be complete for that project: everything it relies on goes into it. - When behaviour changes "for no reason" after you
cdsomewhere, check which file is active (ansible --versionshows it).
Go deeper:
Ansible Configuration Settings (official docs) โ "use the first file found, all others are ignored".