Ansible Study notes 5-playbooks handlers

Source: Internet
Author: User

Handlers action to take when a change occurs


module has idempotent, so when the remote system is changed, you can replay playbooks to achieve recovery

Objective. The playbooks itself can identify this change, and there is a basic event system that can

Respond to this change


Notify actions are triggered at the end of each task in playbook, and even if there are many different

Task notification changes occur, notify actions will only be triggered once


For example, multiple resources indicate that because a configuration file has been changed, Apache needs to re-

The new boot, but the restarted operation will only be executed once


Here is an example of restarting two services when the contents of a file are changed


-Name:template configuration file

Template:src=template.j2 dest=/etc/foo.conf

Notify

-Restart memcached

-Restart Apache

Notify the following is the handlers


Handlers is also a list of some tasks, referenced by their names, and they have nothing to do with the general task

Difference. Handlers is performed notify by the notifier, if not notify,handlers will not be executed

No matter how many notifier notify, wait until all the tasks in play are completed

Handlers will not be executed once.


Here is an example of a handlers

Handlers:

-Name:restart memcached

Service:name=memcached state=restarted

-Name:restart Apache

Service:name=apache state=restarted

The best application scenario for handlers is to restart the service or trigger the system restart operation,

Less use.


This article from "Eight Miles" blog, declined reprint!

Ansible Study notes 5-playbooks handlers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.