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.
More on Roles, Collections and Project Structure
You have a 600-line playbook that sets up web, db and monitoring. How do you restructure it?BeginnerWhere do you put a variable users of your role are expected to override?BeginnerTwo roles need to run in a fixed order, such as `common` before `nginx`.BeginnerA role is used twice with different parameters in one play, but only runs once.IntermediateYou want to share roles across several repos and teams.IntermediateHow do you pin Ansible itself so a CI run today behaves like one last month?Intermediate