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,180 points
348 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,240 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
2,479 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,370 points
860 views
0 votes
0 answers

what is the difference between tags and delegate_to in ansible?

Sep 23, 2019 in Ansible by Rajendra
• 520 points

closed Sep 24, 2019 by Kalgi 176 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,196 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,240 points
126 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,240 points
443 views