Skip to content

Cannot install with a different data directory #699

@pg1671

Description

@pg1671

👻 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions