Interview Prep/Ansible/Roles, Collections and Project Structure

A role must run a task on another host, such as registering with a load balancer.

IntermediateScenarioRoles, Collections and Project Structure
Answer

Situation read → Delegation inside a role.

What I'd do →

- community.general.haproxy:
    backend: web
    host: "{{ inventory_hostname }}"
    state: enabled
  delegate_to: "{{ groups['lb'][0] }}"

Why → Variables still resolve for the original host, while the action runs on the LB.

Interview tip → Be aware ansible_* connection vars come from the delegate host in newer versions; check with -vvv.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Project Structure