gpt4 book ai didi

linux - 在 chef-solo 部署 bash 脚本中检测主机操作系统发行版

转载 作者:IT王子 更新时间:2023-10-29 00:16:03 26 4
gpt4 key购买 nike

部署 chef-solo 设置时,您需要在使用 sudo 或不使用 sudo 之间切换,例如:

    bash install.sh  

    sudo bash install.sh

取决于主机服务器上的发行版。如何实现自动化?

最佳答案

ohai 已经填充了这些属性并且在您的 Recipe 中很容易获得例如,

"platform": "centos",
"platform_version": "6.4",
"platform_family": "rhel",

你可以引用这些作为

 if node[:platform_family].include?("rhel")
...
end

要查看 ohai 设置的其他属性,只需键入

 ohai

在命令行上。

关于linux - 在 chef-solo 部署 bash 脚本中检测主机操作系统发行版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15660887/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com