我使用opscode nginx cookbook来配置我的节点上的nginx服务器。 nginx cookbook有一些默认属性,我想在我的角色(“web_server”)中重写。厨师:我如何覆盖角色中的默认属性?
这些都是我想重写属性:
default['nginx']['version'] = "1.2.2" # in cookbooks/nginx/attributes/default.rb
default['nginx']['source']['prefix'] = "/opt/nginx-#{node['nginx']['version']}" # in cookbooks/nginx/attributes/source.rb
在我的角色/ web_server.rb文件我有这样的事情:
name "web_server"
description "Setup a web server"
run_list "role[base]", "recipe[nginx]"
override_attributes 'nginx' => {
'install_method' => "source",
'version' => "1.2.3",
'source' => { "prefix" => "/opt/nginx", "checksum" => nil }
}
然而,在运行时chef-客户端的nginx配方会忽略我的覆盖并使用默认配置。
我在这里做错了什么?
谢谢!
您是否忘记将角色上传到厨师服务器(如果您正在使用它)? –
您是否运行带有或不带自定义运行列表(-o)的chef-client?今天,我学习了(在调试2-3小时后),在覆盖运行列表时,不会使用角色/节点中设置的属性。 –
我遇到了同样的问题:/我非常确定我在角色中设置了override_attributes,并且我只在我的属性文件中使用了默认值。我敢打赌,这是一种厨师的错误或什么。 –