微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby – 厨师only_if属性等于true

问题:我有一个厨师说明,只有当属性为“true”时才应该运行.但它每次都运行.

预期行为:认情况下,[:quickbase_Legacy_Stack] [:dotNetFx4_Install] =“false”不应该安装dotnet4.

实际行为:无论属性设置为什么,都会安装dotnet4.

我的代码

属性文件

default[:quickbase_Legacy_Stack][:dotNetFx4_Install] = "false"

食谱文件

windows_package "dotnet4" do
    only_if node[:quickbase_Legacy_Stack][:dotNetFx4_Install]=='true'
    source "#{node[:quickbase_Legacy_Stack][:dotNetFx4_URL]}"
    installer_type :custom
    action :install
    options "/quiet /log C:\\chef\\installLog4.txt /norestart /skipmsuinstall"
end

解决方法

运行Ruby的 Guards必须封装在块{}中,否则Chef将尝试在认解释器(通常是bash)中运行字符串.
windows_package "dotnet4" do
    only_if        { node[:quickbase_Legacy_Stack][:dotNetFx4_Install] == 'true' }
    source         node[:quickbase_Legacy_Stack][:dotNetFx4_URL]
    installer_type :custom
    action         :install
    options        "/quiet /log C:\\chef\\installLog4.txt /norestart /skipmsuinstall"
end

检查是否需要布尔值true而不是“true”

另外,使用plain变量名(对于源),除非您需要使用字符串引用来插入其他数据.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐