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变量名(对于源),除非您需要使用字符串引用来插入其他数据.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...