In my attributes file for postgresql recipe I have:
default['postgresql']['pg_hba'] = {
:comment => '# IPv4 local connections',
:type => 'host',
:db => 'all',
:user => 'all',
:addr => '127.0.0.1/32',
:method => 'md5'
}
I want to my recipe automatically add my servers to pg_hga config file like this:
lambda {
if Chef::Config[:solo]
return (Array.new.push node)
end
search(:node, "recipes:my_server AND chef_environment:#{node.chef_environment} ")
}.call.each do |server_node|
node['postgresql']['pg_hba'] << {
:comment => "# Enabling for #{server_node['ipaddress']}",
:type => 'host',
:db => 'all',
:user => 'all',
:addr => "#{server_node['ipaddress']}/32",
:method => 'trust'
}
end
include_recipe 'postgresql'
But I'm receiving an error:
NoMethodError
-------------
Undefined node attribute or method `<<' on `node'
35: node['postgresql']['pg_hba'] << {
36: :comment => "# Enabling for #{server_node['ipaddress']}",
37: :type => 'host',
38: :db => 'all',
39: :user => 'all',
40: :addr => "#{server_node['ipaddress']}/32",
41: :method => 'trust'
42>> }
43: end
44:
45: include_recipe 'postgresql'