what is the difference between tags and delegate_to in ansible?

0 votes
Sep 23, 2019 in Ansible by Rajendra
• 470 points
208 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
• 50,840 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
• 470 points

closed Sep 24, 2019 by Kalgi 53 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
656 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 3 days ago in Ansible by vivek
• 350 points
2,160 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
• 6,910 points
1,979 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
82 views
0 votes
1 answer