Migrating a legacy pre-2.10 playbook that uses short module names to modern Ansible.
IntermediateScenarioRoles, Collections and Project Structure
Answer
Situation read → Short names such as yum: or ec2: break or are ambiguous.
What I'd do →
- Run
ansible-lintand let it flagfqcn. - Use
ansible-lint --fixfor mechanical changes. - Install the collections they now live in (
amazon.aws,community.general). - Replace removed modules (
ec2becomesec2_instance).
Why → FQCNs make the source of every module explicit.
Interview tip → Core builtins are ansible.builtin.*.
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