chef client cancel notifies delayed

给你一囗甜甜゛ 提交于 2019-12-11 09:12:54

问题


I am wondering if there is a way to cancel a notification to restart a service that was set to delayed. For example, here is a configuration change code block:

template "/etc/myapp/myconfig.conf" do
    source "myconfig.conf.erb"
    mode 0600
    notifies :restart, "service[myapp]", :delayed
end

But then at the end of my recipe, I have some logic that will actually disable the app if certain conditions are met. This works fine, but then just after the disable (at the end of the chef run), the delayed restart request kicks in and restarts the process. I'm wondering if there is a way to tell chef to cancel all restart requests for the service if it get's disabled. Thoughts?


回答1:


It can be done, but it is not pretty. You would need to reach into the [run_context][1] and get a hold of the [delayed_notification_collection][2]. You could then remove the notification. But be aware, this is mucking pretty deeply into the internals of chef, which is highly discouraged.

take a look at this "cookbook" for an example. It's only been tested to the extent that the test-kitchen tests exercise it.



来源:https://stackoverflow.com/questions/26655604/chef-client-cancel-notifies-delayed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!