23 lines
379 B
Markdown
23 lines
379 B
Markdown
## Handlers
|
|
|
|
Handlers are tasks that only run when notified by other tasks (typically after a change):
|
|
|
|
```yaml
|
|
- name: Install nginx
|
|
hosts: webservers
|
|
tasks:
|
|
- name: Install nginx
|
|
apt:
|
|
name: nginx
|
|
state: present
|
|
notify: Restart nginx
|
|
|
|
handlers:
|
|
- name: Restart nginx
|
|
service:
|
|
name: nginx
|
|
state: restarted
|
|
```
|
|
|
|
---
|