what is the difference between tags and delegate to in ansible

0 votes
Sep 23, 2019 in Ansible by Rajendra
• 510 points
1,948 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, 2019 by Kalgi
• 52,350 points

Related Questions In Ansible

0 votes
0 answers

what is the difference between tags and delegate_to in ansible?

Sep 23, 2019 in Ansible by Rajendra
• 510 points

closed Sep 24, 2019 by Kalgi 845 views
0 votes
1 answer

What is the difference between the host file and an inventory file in ansible?

Actually both are same. hosts file is ...READ MORE

answered Feb 12, 2019 in Ansible by Amith
• 140 points
8,064 views
+1 vote
2 answers

What is the difference between ansible playbook and roles?

Hi, Roles: Roles containing certain vars_files, tasks, and handlers ...READ MORE

answered Jan 21, 2020 in Ansible by vivek
• 530 points
21,882 views
0 votes
1 answer
0 votes
1 answer

What is the ask_pass module in Ansible?

Hi@akhtar, Ask_pass is the control module in an ...READ MORE

answered Aug 11, 2020 in Ansible by MD
• 95,460 points
3,088 views
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
• 7,340 points
6,913 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, 2019 in Ansible by Priya
1,054 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP