Can I notify the handler in another role? What should I do to make ansible find it?
The use case is, e.g. I want to configure some service and then restart it if changed. Different OS have probably different files to edit and even the file format can be different. So I would like to put them into different roles (because the file format can be different, it can’t be done by setting group_vars). But the way to restart the service is the same, using
service module; so I’d like to put the handler to
Is anyway to achieve this? Thanks.
You can also call handlers of a dependency role. May be cleaner than including files or explicitly listing roles in a playbook just for the purpose of role to role relationship. E.g.:
Default123456---- name: nginx restartservice: >name=nginxstate=restarted
Default1234---dependencies:- role: my-handlers
Default123456---- copy: >src=nginx.confdest=/etc/nginx/notify: nginx restart