what is the difference between tags and delegate_to in ansible?

0 votes
Sep 23 in Ansible by Rajendra
• 470 points
132 views

1 answer to this question.

0 votes

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
answered Sep 24 by Kalgi
• 46,110 points

Related Questions In Ansible

0 votes
0 answers

what is the difference between tags and delegate_to in ansible?

Sep 23 in Ansible by Rajendra
• 470 points

closed Sep 24 by Kalgi 45 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 6,890 points
1,804 views
0 votes
1 answer
0 votes
1 answer

What are the different types of plugins available in Ansible?

Ansible provides a huge variety of plugins ...READ MORE

answered Feb 19 in Ansible by Priya
79 views
0 votes
1 answer