Interview Prep/Ansible/Variables, Facts and Templates

A teammate puts `ansible_python_interpreter` in every play. Where should it live?

BeginnerScenarioVariables, Facts and Templates
Answer

Situation read → Connection config duplicated.

What I'd do → Move it to inventory (group_vars/all.yml or host vars), or set interpreter_python = auto_silent in ansible.cfg.

# group_vars/legacy.yml
ansible_python_interpreter: /usr/bin/python3.9

Why → It is a property of the host, not the play.

Interview tip → Modern Ansible discovers Python automatically (auto).

All Ansible questions Roadmap: Ansible

More on Variables, Facts and Templates