Your role's tasks directory has grown to a single 400-line file.
BeginnerScenarioRoles, Collections and Project Structure
Answer
Situation read → Poor readability.
What I'd do → Split into files and include them.
# tasks/main.yml
- ansible.builtin.import_tasks: install.yml
- ansible.builtin.import_tasks: configure.yml
- ansible.builtin.import_tasks: service.yml
Tag each import so users can run only configure.
Why → Small files with a clear name map to the lifecycle and are easy to review.
Interview tip → import_tasks is static (parsed upfront); include_tasks is dynamic (needed for loops or runtime filenames).
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