Here is a weird thing:
When running /etc/init.d/milter-greylist restart via ansible (either direct or via a playbook) it hangs. I had no time to debug this, so I reverted to the next best workaround since the machine was already running monit:
Have ansible distribute greylist.conf and then have monit restart the process. So here is a simple playbook:
- hosts: greylist
user: root
tasks:
- name: copy local milter-greylist configuration to hosts
action: copy src=/usr/local/etc/greylist.conf dest=/etc/milter-greylist/greylist.conf
and here is how monit finishes the task:
check file greylist.conf with path /etc/milter-greylist/greylist.conf if changed checksum then exec "/etc/init.d/milter-greylist restart"
Of course this is just a simple case of having the two cooperate. But once you get the hang of it, more elaborate schemes where ansible and monit can cooperate will pop out.