A role requires a handler from another role.
AdvancedScenarioRoles, Collections and Project Structure
Answer
Situation read → Cross-role notification.
What I'd do → Handlers are global to the play, so a task can notify by name. But this couples roles; better to use listen topics.
# role A
notify: "reload web stack"
# role B handler
- name: Reload nginx
ansible.builtin.service: { name: nginx, state: reloaded }
listen: "reload web stack"
Why → A topic name is a stable contract; handler names are not.
Interview tip → Include roles dynamically with include_role and handlers become visible only after that point.
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