加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby – 厨师only_if属性等于true

发布时间:2020-12-16 21:53:12 所属栏目:百科 来源:网络整理
导读:问题:我有一个厨师说明,只有当属性为“true”时才应该运行.但它每次都运行. 预期行为:默认情况下,[:QuickBase_Legacy_Stack] [:dotNetFx4_Install] =“false”不应该安装dotnet4. 实际行为:无论属性设置为什么,都会安装dotnet4. 我的代码: 属性文件:
问题:我有一个厨师说明,只有当属性为“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:chefinstallLog4.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:chefinstallLog4.txt /norestart /skipmsuinstall"
end

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读