What is Handlers in Ansible

0 votes

Hi Guys,

I am new to Ansible. I have created one playbook. Can anyone tell me how can I use handlers in Ansible?

Aug 20, 2020 in Ansible by akhtar
• 38,260 points
1,276 views

1 answer to this question.

0 votes

Hi@akhtar,

Handlers are just like normal tasks in an Ansible playbook but they run only when if the Task contains a “notify” directive. It also indicates that it changed something. I have attached one example below.

- name: webserver
  hosts: WORKSPACE
  tasks:
         - name: Install nginx
           package:
             name: nginx
             state: present
           notify:
                Start nginx
  handlers:
       - name: Start nginx
         service:
           name: nginx
           state: started
answered Aug 20, 2020 by MD
• 95,460 points

Related Questions In Ansible

0 votes
1 answer
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,070 views
0 votes
1 answer

what is the difference between tags and delegate_to in ansible?

Hey @Rajendra, If you wish to perform ...READ MORE

answered Sep 24, 2019 in Ansible by Kalgi
• 52,350 points
1,951 views
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 848 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,065 views
+2 votes
1 answer
0 votes
1 answer

What is a template in Ansible?

Hi@akhtar, Managing configurations of multiple servers and environments are ...READ MORE

answered Aug 2, 2020 in Ansible by MD
• 95,460 points
735 views
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,090 views
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