puppetlabs / puppetlabs/puppetlabs-postgresql

don't set data_directory in the config by default

Open
#1,576 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

community
Dominant language
Ruby
Stars
232
Forks
610
Avg merge
5d 23h
Merged PRs (30d)
4

Description

Describe the Bug

Today, we always set data_directory = … in postgresql.conf via
https://github.com/puppetlabs/puppetlabs-postgresql/blob/411e7bce3f2d5256c315351144dc525b6c0afbbe/manifests/server/instance/config.pp#L222-L225

However we also set it in the systemd override:
https://github.com/puppetlabs/puppetlabs-postgresql/blob/411e7bce3f2d5256c315351144dc525b6c0afbbe/manifests/server/instance/systemd.pp#L29-L34
https://github.com/puppetlabs/puppetlabs-postgresql/blob/411e7bce3f2d5256c315351144dc525b6c0afbbe/templates/systemd-override.conf.epp#L11

And pass it when calling initdb:
https://github.com/puppetlabs/puppetlabs-postgresql/blob/411e7bce3f2d5256c315351144dc525b6c0afbbe/manifests/server/instance/initdb.pp#L153

The problem is that setting data_directory in the config actually overrides the -D parameter on the CLI and the PGDATA environment variable, as can be seen in e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1935301 thus possibly breaking future actions against this DB (see the link for an example, also https://www.postgresql.org/message-id/3566642.1618422939%40sss.pgh.pa.us).

Expected Behavior

data_directory not set in postgresql.conf when systemd is used and thus the environment variable is present

Steps to Reproduce

install a postgresql setup :)

Environment

  • Version 10.0.3
  • Platform CentOS Stream 8

Additional Context

This is the exact opposite of #510 🤷‍♀️

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading manifests/server/instance/config.pp, systemd.pp, initdb.pp, and templates/systemd-override.conf.epp at the referenced sections to trace how data_directory is supplied. Verify the PostgreSQL systemd setup and initdb behavior, then confirm that postgresql.conf omits data_directory while the systemd override and initdb invocation still provide the data path.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.