Hey @Rajendra, If you wish to perform a task on one host with reference to the other that's exactly when you use delegate_to. This is very useful when you've to add nodes to load balancers.
Example:
- name: add back to load balancer pool
command: /usr/bin/add_back_to_pool {{ inventory_hostname }}
delegate_to: 127.0.0.1
Whereas tag, on the other hand, is just some name assigned to a section of code. Say suppose you have three sections in your code. In the first case, you need to execute only the first and all three in the second.
You can tag these sections of the code and use the following flag for achieving what you need.
--tags or --skip-tags