我正在尝试使用opscode LWRP安装postgresql。我收到错误
You must set node['postgresql']['password']['postgres'] in chef-solo mode
这是我的食谱
include_recipe 'postgresql::server'
我见过的所有文档都描述了使用节点,但我想将下面的json代码等同于使用属性的配方。有没有办法做到这一点?
"postgresql" : {
"config": {
"ssl": "false",
"listen_addresses": "*"
},
"password" : {
"postgres" : "1234"
},
"pg_hba": [
{ "type": "host", "db": "all", "user": "postgres", "addr": "119.9.40.50/32", "method": "md5" }
]
},
完整错误在这里
28: missing_attrs = %w{
29: postgres
30: }.select do |attr|
31: node['postgresql']['password'][attr].nil?
32: end.map { |attr| "node['postgresql']['password']['#{attr}']" }
33:
34: if !missing_attrs.empty?
35>> Chef::Application.fatal!([
36: "You must set #{missing_attrs.join(', ')} in chef-solo mode.",
37: "For more information, see https://github.com/opscode-cookbooks/postgresql#chef-solo-note"
38: ].join(' '))
39: end
40: else
41: # TODO: The "secure_password" is randomly generated plain text, so it
42: # should be converted to a PostgreSQL specific "encrypted password" if
43: # it should actually install a password (as opposed to disable password
44: # login for user 'postgres'). However, a random password wouldn't be
答案 0 :(得分:1)
将以下行添加到食谱中的attributes/default.rb
:
default['postgresql']['password']['postgres'] = "xxx"
这不会将其“添加到使用属性的食谱中”,但会将其添加到食谱中。您也可以直接在食谱中设置属性,但我认为现在没有理由这样做(您可以使用node.default[...]
执行此操作。)
(您可以选择以.rb
结尾的任何文件名,但不一定是default.rb
,但我会说这是一种约定)