[英]Can I install two chef clients on a Linux server so that both two clients can manage the linux server?
I want to install one chef client on a linux server to manage the server by executing shell command. 我想在Linux服务器上安装一个Chef客户端,以通过执行shell命令来管理服务器。 While there is a reboot command in one of the recipes in the run list, and the rest recipes don't continue to execute after the server reboot.
在运行列表的配方之一中有一个重新启动命令时,其余配方在服务器重新启动后不会继续执行。 As I haven't found a way to solve it, I wonder if I can install two chef clients on a Linux server and execute different recipes so that the rest recipes can continue to execute after the server reboot.
由于找不到解决方法,我想知道是否可以在Linux服务器上安装两个Chef客户端并执行不同的配方,以便其余配方可以在服务器重新启动后继续执行。 Anyone can help?
有人可以帮忙吗? Thanks.
谢谢。
Putting two clients on a single device, or two Configuration Management tools on the same box in general, is a Bad Idea. 通常将两个客户端放在单个设备上,或者将两个配置管理工具放在同一盒中是一个坏主意。 Even if you could do it the cognitive load increase from determining when to update what where going forward is going to open you up to mistakes.
即使您能够做到,但从确定何时更新前进的方向将使您面临错误的认知负担会增加。
The proper approach is to put restart flags in your recipes; 正确的方法是在配方中放置重新启动标志。 before you call the restart resource you set a flag (which can be a files contents or even existence, an environment variable, or any number of other persistent data objects) to indicate that a restart was performed.
在调用重新启动资源之前,您需要设置一个标志(可以是文件内容甚至存在,环境变量或任意数量的其他持久数据对象),以指示已执行重新启动。 If its to be periodic you can instead look at something like the last time a file was accessed with its
atime
property. 如果它是周期性的,则可以改用上次使用
atime
属性访问文件的方式来查看。 Then you do logic around your steps that require a reboot, guarding against a reboot if the flag no-restart flag is set or triggering it if you have a restart flag set, your choice. 然后,围绕需要重新启动的步骤执行逻辑,如果设置了标志no-restart标志,则防止重新启动;如果设置了重新启动标志,则触发该重新启动。 That way you'll have a chef converge with a restart that skips part of your runlist, then later another run that skips the unnecessary restart process.
这样一来,您将拥有一个厨师,其厨师将重新启动,从而跳过部分运行列表,然后再进行另一次运行,从而跳过不必要的重新启动过程。
Another good option is to just pay more attention to how you have your resources ordered. 另一个不错的选择是只是更加注意如何订购资源。 If the restart is in your last runlist item and is notified with the
:delayed
timing then it will be the last run resource, meaning the rest of your recipes would have already converged. 如果重新启动位于您的最后一个运行列表项中,并通过
:delayed
定时通知,则它将是最后一次运行的资源,这意味着其余食谱将已经收敛。 If you need a complete converge every time then that is the option you should embrace. 如果您每次都需要一次完全收敛,那么您应该选择该选项。
Option 1 is a Ruby-centric solution and will require you to embrace dev work. 选项1是一个以Ruby为中心的解决方案,将需要您接受开发工作。 Option 2 is more pure Chef with some Ruby sprinkled in and you can read up on notifying resources in the docs here: https://docs.chef.io/resource_common.html#notifications
选项2更纯净,带有一些Ruby,您可以在以下文档中阅读有关通知资源的信息: https : //docs.chef.io/resource_common.html#notifications
There is an option 3 where you change the runlist during the chef run, which you could use to remove the recipes that require the reboot, but I think you'd benefit more from option 1 or 2. 有一个选项3,您可以在厨师运行期间更改运行列表,可以用来删除需要重新启动的配方,但是我认为您将从选项1或2中受益更多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.