postgresql
postgresql copied to clipboard
Cannot install with a different data directory
:ghost: Brief Description
Cannot change the default_data_directory. I can update the postgresql.conf file to /data/postgresql but the service running on ubuntu is still using the default location via the -D command.
/usr/lib/postgresql/13/bin/postgres -D /var/lib/postgresql/13/main -c config_file=/etc/postgresql/13/main/postgresql.conf
I think this is because the server needs to be reloaded after the server config is set but when I include the notifies directive on the server config block I get an error. Chef::Exceptions::ResourceNotFound occurred in Chef Infra Client run: resource postgresql_server_conf[PostgreSQL Config] is configured to notify resource service[postgresql] with action reload, but service[postgresql] cannot be found in the resource collection.
:pancakes: Cookbook version
Latest 10.0.0
:woman_cook: Chef-Infra Version
17.8.25
:tophat: Platform details
Ubuntu 20.04.3
Steps To Reproduce
Steps to reproduce the behavior, the notifies line causes the error.
postgresql_server_install 'My Postgresql Server install' do
version node['app']['postgres_version']
action :install
end
directory "/data/postgresql" do
owner 'postgres'
group 'postgres'
mode 0700 # Owner only can rwx
action :create
recursive true
end
postgresql_server_conf 'PostgreSQL Config' do
version node['app']['postgres_version']
data_directory '/data/postgresql'
additional_config 'listen_addresses' => '*'
notifies :reload, 'service[postgresql]'
end
# Create the Database Instance
# moved here after setting config to try to get it to use the overridden data_directory
postgresql_server_install 'My Postgresql Server install' do
version node['app']['postgres_version']
password node['app']['postgres_password']
action :create
end
:police_car: Expected behavior
After install the database is created in the new directory and the postgresql service is correctly using the correct data directory via the -D command line option.
:heavy_plus_sign: Additional context
None