4

我想做这样的事情:

属性/default.rb

if node[:chef_environment] == 'dev'
   include_attribute "mbev::dev"
else
   include_attribute "mbdev::production"
end

但似乎“节点”等于当前节点的名称。

4

2 回答 2

8

试试node.chef_environment?它是一个返回值而不是属性的函数。

于 2013-10-28T15:14:12.513 回答
2

Inside an attribute file, I think you want to use just chef_environment, according to this post in the Chef Mailing List, and independently confirmed by me.

Your attribute file should then look like this:

if chef_environment == 'dev'
    include_attribute "mbev::dev"
else
    include_attribute "mbdev::production"
end

node.chef_environment will work in recipes.

于 2014-08-05T20:44:01.513 回答