使用 Chef 卸载软件包
我一直在使用 Chef 来管理我们的服务器。
我的 Roles/app.rb 如下所示:
name "app"
description "App server"
run_list [
"recipe[apt]",
...,
...,
"recipe[nginx]"
...,
...,
]
现在我想从计算机中删除 nginx 包。 如果我删除 run_list 中的 nginx recipie,它会从节点中删除 nginx 吗?如果没有,请告诉我在节点上进行变更管理的最佳策略是什么。
I have been using Chef to manage our servers.
My roles/app.rb looks like this:
name "app"
description "App server"
run_list [
"recipe[apt]",
...,
...,
"recipe[nginx]"
...,
...,
]
Now I would like to remove the nginx package from the machine.
If I remove the nginx recipie in run_list, will it remove nginx from the nodes? If not please advise me what is the best strategy to have change-management on nodes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您从 run_list 中删除 nginx,则该特定配方将不会运行。它实际上不会从节点中删除 nginx,因为它不知道如何删除。其实我昨天也在思考这个问题。
您可以编写自己的配方来撤消配方[nginx]也许配方[remove_nginx]或类似的东西。接下来,您可以删除配方[remove_nginx]。
其他人也认为这是一种做事的好方法,至少让人有点放心:
http://community.opscode.com/ questions/6
显然,您可以从 ruby_block 中的 run_list 中删除配方,这样就可以省去在运行后使用刀自行删除它的麻烦:
https://gist.github.com/883522
If you remove nginx from the run_list that particular recipe just won't run. It won't actually remove nginx from the nodes because it doesn't know how to. I was actually pondering about this yesterday.
You can write your own recipe which undoes recipe[nginx] maybe recipe[remove_nginx] or something like that. Following that you can then remove recipe[remove_nginx].
Someone else also thinks this is a good way to do things which is at least a little reassuring:
http://community.opscode.com/questions/6
Apparently you can remove a recipe from the run_list in a ruby_block, so that saves you the hassle of using knife to remove it yourself after it is run:
https://gist.github.com/883522