簡體   English   中英

Chef-solo不更新postgres pg_hba.conf

[英]chef-solo not updating postgres pg_hba.conf

我正在使用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文件。 是什么阻止了它們的編寫?

似乎數據框食譜使用node.set 覆蓋了Postgres權限數組,而不是僅僅修改它所需的部分。

我已經向該項目提交了拉取請求 ,以更改此行為,以便可以將其他條目添加到文件中。

我在廚師獨奏中也遇到了同樣的問題。 我的出路是為pg_hba.conf創建一個模板,並在執行配方結束時將其替換。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM