Mac-Osx
在 OSX 目標上使用 Ansible 重新啟動守護程序的正確方法是什麼?
我創建了一個簡單的 Ansible 角色,目的是在 OSX 目標上配置 dnsmasq(dnsmasq 是從自製軟體安裝的)。
我想創建一個處理程序,當配置文件發生更改時將重新啟動守護程序(從 1.9.3 版開始的 Ansible 不為 OSX 實現服務模組)。
我有一個任務:
- 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
其中
/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
有一個鍵<key>KeepAlive</key>
在不執行時自動啟動守護程序,因此以下處理程序完成其工作。我可以一直依靠這個嗎?- name: restart dnsmasq sudo: yes command: launchctl stop homebrew.mxcl.dnsmasq
沒有任何場景或時間問題會導致守護程序永久停止嗎?編寫此類處理程序的正確方法是什麼?
來自
launchctl(1)
:stop label Stop the specified job by label. If a job is on-demand, launchd may immediately restart the job if launchd finds any criteria that is satisfied.
所以我假設這
KeepAlive
會導致守護程序重新啟動,儘管該子命令在LEGACY SUBCOMMANDS塊中已關閉,所以蘋果可能會在未來的某個時候將其刪除?kickstart -k
看起來它會執行啟動或重新啟動,並且不在舊版塊中……