[Ansible] – Understanding Handlers

Handlers are used to trigger actions when the tasks are executed. For example, in the case of being required to start some service after an installation then a handler to restart the service could be called. Following an example.

- name: Handler exemple
  hosts: all
  - name: Copy content 
      content: "Copy content to the index.html file"
      dest: /var/www/html/index.html
      - restart_service 
  - name: restart_service 
      name: mongodb 
      state: restarted

NOTE: The notify attribute is used to call the handler and the handlers are called by the name.

For further information see the Intro to Playbooks documentation.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s