Interview Prep/Ansible/Roles, Collections and Project Structure

A role repo and a playbook repo each carry their own `ansible.cfg`. Which one wins?

IntermediateScenarioRoles, Collections and Project Structure
Answer

Situation read → Config lookup order.

What I'd do → Know the order: ANSIBLE_CONFIG env var, then ./ansible.cfg in the current directory, then ~/.ansible.cfg, then /etc/ansible/ansible.cfg. Only one file is used; they do not merge. Check with ansible --version (shows config file) and ansible-config dump --only-changed.

Why → The working directory at invocation decides; world-writable directories are ignored for security.

Interview tip → Mention the "ignoring ansible.cfg in a world writable directory" warning.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Project Structure