我正在使用Chef Solo来配置Vagrant虚拟机。这是相关的Vagrantfile片段:
chef.run_list = [
"databox::default",
"mydbstuff"
]
chef.json = {
"postgresql": {
"config" : {
"listen_addresses": "*"
},
"pg_hba": [
{"type": "local", "db": "all", "user": "postgres", "addr": null, "method": "ident"},
{"type": "local", "db": "all", "user": "all", "addr": null, "method": "md5"},
{"type": "host", "db": "all", "user": "all", "addr": "127.0.0.1/32", "method": "md5"},
{"type": "host", "db": "all", "user": "all", "addr": "::1/128", "method": "md5"},
{"type": "local", "db": "all", "user": "vagrant", "addr": null, "method": "ident"},
{"type": "host", "db": "all", "user": "all", "addr": "192.168.248.1/24", "method": "md5"}
]
},
"databox": {
"db_root_password": "abc123",
"databases": {
"postgresql": [
{ "username": "db1", "password": "abc123", "database_name": "db1" },
{ "username": "db2", "password": "abc123", "database_name": "db2" }
]
}
}
}
mydbstuff::default
食谱如下所示:
postgresql_connection_info = {
:host => "localhost",
:port => node['postgresql']['config']['port'],
:username => 'postgres',
:password => node['postgresql']['password']['postgres']
}
postgresql_database_user 'vagrant' do
connection postgresql_connection_info
password 'vagrant'
action :create
end
node['databox']['databases']['postgresql'].each do |db|
postgresql_database_user 'vagrant' do
connection postgresql_connection_info
action :grant
database_name db.database_name
end
end
我正在尝试允许本地vagrant
用户在没有密码的情况下以及VirtualBox专用网络中的任何用户进行连接。我的pg_hba
中的chef.json
数组有四行从默认配置中复制,两行用于执行我想要执行的其他操作。 如果我手动将这两行添加到pg_hba.conf
文件中,它们就可以正常工作。
问题是我的更改实际上并未写入pg_hba.conf
文件。什么阻止他们被写?
答案 0 :(得分:0)
使用node.set
似乎是数据手册食谱overwrites the Postgres permissions array,而不仅仅是修改它所需的部分。
我已将a pull request提交给项目以更改此行为,以便可以将其他条目添加到文件中。
答案 1 :(得分:0)
我遇到了与厨师独唱相同的问题。我的出路是为pg_hba.conf创建一个模板,并在执行配方结束时替换。