Ideally, I'd like to be able to do something like:
- include: deregister_from_loadbalancer.yml
delegate_to: loadbalancer
In such a way that I still have access to the vars for the host I'm running the overall play against, but actions are taking place on the loadbalancer host.
Why not separate plays?
I can't just break this into separate plays, because I'm taking machines out of loadbalancer rotation one-at-a-time. Separating into multiple plays would mean something like:
- hosts: loadbalancers
tasks:
- include: remove_from_loadbalancer.yml
vars:
machine: "{{ item }}"
with_items: "{{ groups['webservers'] }}"
# at this point in the play I'm being fired for gross incompetence
- hosts: webservers
tasks:
# ... update them
- hosts: loadbalancers
tasks:
- include: add_to_loadbalancer.yml
vars:
machine: "{{ item }}"
with_items: "{{ groups['webservers'] }}"