当试图在vagrant almalinux/9上安装supermarket.io的postgresql v13+时出现错误

我想使用 supermarket.io 的 PostgreSQL 配方来在 vagrant 的 almalinux/9 上安装 PostgreSQL 13 等,但似乎在最近的版本中,安装时需要执行 dnf -qy module disable ‘postgresql’ 的命令,以便不参考原始包,但执行该命令时出错。

为什么不安装“postgresql”这样的包呢?因为不想麻烦地编辑pg_hba.conf文件、添加默认用户等琐碎的操作。

因此,在执行 berks update 之后,需要重写postgresql配方的一部分。

Berksfile 的中文同义词:博克斯文件

source "https://supermarket.chef.io"

cookbook 'postgresql', '~>  11.2.3', :supermarket

我自己的PostgreSQL的配方

#
# Cookbook:: pgsql
# Recipe:: default
#
# Copyright:: 2022, The Authors, All Rights Reserved.

postgresql_client_install 'My PostgreSQL Client install' do
    version '14'
    action :install
end

postgresql_server_install 'My PostgreSQL Server install' do
    version '14'
    initdb_locale 'ja_JP.UTF-8'
    initdb_encoding 'UTF8'
    action [:install, :create]
end

postgresql_server_conf 'PostgreSQL Config' do
    additional_config({
        :listen_addresses => '*'
    }) 
    notifies :restart, 'service[postgresql]'
end
postgresql_access 'postgresql access' do
    access_type       'host'
    access_db         'all'
    access_user       'all'
    access_addr       '192.168.56.0/24'
    access_method     'password'
    notifies :restart, 'service[postgresql]'
end
postgresql_access 'postgresql local access' do
    access_type       'host'
    access_db         'all'
    access_user       'all'
    access_addr       '127.0.0.1/32'
    access_method     'password'
    notifies :restart, 'service[postgresql]'
end

postgresql_database 'postgresql database' do
    database          'testdb'
    encoding          'UTF8'
    template          'template0'
    locale            'ja_JP.UTF-8'
end
postgresql_database 'wellness database' do
    database          'wellness'
    encoding          'UTF8'
    template          'template0'
    locale            'ja_JP.UTF-8'
end
postgresql_database 'wellness_personal database' do
    database          'wellness_personal'
    encoding          'UTF8'
    template          'template0'
    locale            'ja_JP.UTF-8'
end

postgresql_user 'postgresql user' do
    create_user       'testuser'
    password          'password'
end
postgresql_user 'wellness user' do
    create_user       'wellness'
    password          'password'
end
postgresql_user 'craft user' do
    create_user       'craft'
    password          'craft1234!'
end

service 'postgresql' do
    service_name 'postgresql-14'
    supports restart: true, status: true, reload: true, enable: true
    action [:enable, :reload]
end

修改 chef-repo\cookbooks\postgresql\resources\repository.rb

    # 21行目付近のブロックを削除/コメントアウト
    ## dnf_module 'postgresql' do
    ##   action :disable
    ##   only_if { node['platform_version'].to_i >= 8 && platform_family?('rhel', 'fedora') }
    ## end