2014-02-11 68 views
1

我想使用opscode LWRP安裝postgresql。我得到一個錯誤廚師 - 如何使用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  

回答

1

以下行添加到attributes/default.rb在您的食譜:

default['postgresql']['password']['postgres'] = "xxx" 

這不添加它「到使用屬性配方」,但它將它添加到食譜中。你也可以直接在食譜中設置屬性,但我現在沒有理由這樣做(你可以在node.default[...]的地方做到這一點)。

(你可以選擇.rb結尾的文件名,它並沒有成爲default.rb,但我會說這是有點約定)

+0

同樣的錯誤。我已經嘗試過了。我只想使用一個配方,遠離節點和角色。 – markhorrocks

+1

你不能避免節點。節點是運行廚師的東西。我的意思是「你的食譜」:你是否在節點的運行列表中添加了一個額外的菜譜,在該列表中放置了我上面提到的那一行?你的代碼在github上?會讓事情變得更容易。 – StephenKing

+0

我已經爲你抓了一個小小的包裝食譜:https://gist.github.com/StephenKing/8939285 只需創建精靈所需的文件作爲新的烹飪書my_postgresql並添加recipe [my_postgresql]到節點的運行列表而不是'recipe [postgresql :: server]'。我希望這有幫助。 – StephenKing