Trigger tasks with handlers
Okay; you have installed and removed a series of packages in your system. You have copied files to/from your server. And you have changed many things in the server by using an Ansible playbook. Now, you need to restart a few other services, or add some lines to the files, to complete the configuration of the service. So, you should add a new task, right? Yes, that's correct. However, Ansible provides another great option, called handlers, which will not automatically execute when it hits (unlike tasks), but will rather be executed only when it is called. This provides you with the flexibility to call them upon the execution of tasks inside the play.
Handlers have the same alignment as the hosts and tasks, and are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access