How do you pin Ansible itself so a CI run today behaves like one last month?
IntermediateScenarioRoles, Collections and Project Structure
Answer
Situation read → Tool-version drift.
What I'd do →
- Pin
ansible-coreand Python dependencies inrequirements.txt(and lock hashes). - Pin collections in
requirements.yml. - Better, bake both into an Execution Environment image or a container used by CI.
ansible-core==2.17.*
Why → Module behaviour changes between versions; a floating install makes failures irreproducible.
Interview tip → Say you upgrade deliberately on a schedule with a test run.
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.IntermediateA role installs a package and writes a config, but must support Ubuntu and Rocky Linux.Intermediate