Quiz Entry - updated: 2026.10.30
In which order does Ansible look for its configuration file, and which one wins?
ANSIBLE_CONFIG (environment variable) first, then ./ansible.cfg in the current directory, then ~/.ansible.cfg in the home directory, and only then /etc/ansible/ansible.cfg. The first file found is used.
* Ansible walks down this list and stops at the first file it finds. *
ANSIBLE_CONFIG: if this environment variable points to a file, that file overrides everything else../ansible.cfg: a file in the directory where you run theansiblecommand. This is what makes per-project settings work.~/.ansible.cfg: the user's personal file in the home directory./etc/ansible/ansible.cfg: the global base file shipped with the package, used only if nothing else is found.- If even that is missing, Ansible uses its built-in defaults.
The more specific and more deliberate a source is, the higher it ranks: an explicit variable beats the project, the project beats the user, the user beats the system.
Tip: read it bottom-up as the order in which they were introduced (global, personal, project, variable); the search order is the reverse.
Go deeper:
Ansible Configuration Settings: the configuration file (official docs) โ the search order and the rule that the first file found wins.