Setting task execution delegation
In every play we have run so far, we have assumed that all the tasks are executed on each host in the inventory in turn. However, what if you need to run one or two tasks on a different host? For example, we have talked about the concept of automating upgrades on clusters. Logically, however, we would want to automate the entire process, including the removal of each host in turn from the load balancer and their return after the task is completed.
Although we still want to run our play across our entire inventory, we certainly don’t want to run the load balancer commands from those hosts. Let’s once again explain this in more detail with a practical example. We’ll reuse the two simple host inventories that we used earlier in this chapter:
[frontends] frt01.example.com frt02.example.com
Now, to work on this, let’s create two simple shell scripts in the same directory as our playbook. These are only examples, as setting...