I created a simple Ansible role with the purpose of configuring dnsmasq on OSX targets (dnsmasq is installed from homebrew).
I want to create a handler that would restart the daemon when configuration file gets changed (Ansible as of version 1.9.3 does not implement service module for OSX).
I have a task:
- name: Create dnsmasq config file in /usr/local/etc/ from template template: src=dnsmasq.conf.j2 dest=/usr/local/etc/dnsmasq.conf notify: - restart dnsmasq In /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist there is a key <key>KeepAlive</key> which starts the daemon automatically when not running, so the following handler does its job. Can I always rely on this?
- name: restart dnsmasq sudo: yes command: launchctl stop homebrew.mxcl.dnsmasq Aren't there any scenarios or timing issues that would result in the daemon getting permanently stopped? What would be the proper way for such handler to be written?