这个厨师食谱代码是什么意思

What does this chef cookbook code means

我有以下食谱。

execute 'disable-all-yum-repos-centos' do
  command 'yum-config-manager --disable "*"'
  action :run
  only_if { centos? }
end

现在,{ centos 是什么意思? } 在这里的意思是,它是一个被调用的变量吗?或者一些内置函数,据我所知,如果在字符串中,变量被称为 node[variable name] 或 #{ node[variable name]} ,上面提到的东西对我来说是新的,帮助我理解。

我知道它正在检查 os 是否为 centos,但是,这是什么语法?以及这是如何评估的。

这是一个包含在块中的函数调用。如果你放下方块,Chef会调用系统命令,你可以看到more examples in the documentation.

您的代码似乎使用了 chef-sugar cookbook, centos? method is defined here