sous-chefs / sous-chefs/postgresql
Cannot install with a different data directory
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 376
- Forks
- 552
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
👻 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.
🥞 Cookbook version
Latest 10.0.0
👩🍳 Chef-Infra Version
17.8.25
🎩 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
🚓 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.
➕ Additional context
None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the postgresql_server_install and postgresql_server_conf resources in the reproduced Chef recipe, focusing on the service[postgresql] notification error. Trace how data_directory, service creation, and the -D argument interact; done means the database is created in /data/postgresql and the service uses that directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, ruby
- Domain
- database, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100