Fix Debian PostgreSQL setup: create cluster if missing and target version-specific systemd unit#63
Open
nuz014 wants to merge 2 commits into
Open
Fix Debian PostgreSQL setup: create cluster if missing and target version-specific systemd unit#63nuz014 wants to merge 2 commits into
nuz014 wants to merge 2 commits into
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related fixes for running this role against Debian/Ubuntu hosts, surfaced while
installing PostgreSQL 18 (incl. side-by-side with an existing cluster).
1. Ensure the Debian/Ubuntu cluster exists before configuring it
The role assumed the
postgresql-NNpackage's postinst had already created themaincluster viapg_createcluster. When that auto-creation is skipped or fails(locale issues,
create_main_cluster=falseincreatecluster.conf, or the configdir already existing),
/etc/postgresql/NN/main/postgresql.confis never written andthe role fails with a confusing error two tasks later:
TASK [galaxyproject.postgresql : Check for conf.d include in postgresql.conf]
Destination /etc/postgresql/18/main/postgresql.conf does not exist !
Worse, the
Create conf.dtask silently creates the empty/etc/postgresql/NN/main/parent directory, which then blocks a later
pg_createclusterand makes the failuresticky across re-runs.
This PR adds an explicit, idempotent cluster-creation step to
tasks/debian.yml(guarded by
creates:) that runs beforeCreate conf.d, so the cluster is alwaysin place before the role writes any config into it. On hosts where the cluster already
exists it is a no-op.
2. Target the version-specific systemd unit on Debian instead of the meta-service
On Debian,
postgresql_service_namewas thepostgresqlmeta-service. That oneshot isalready
activewhenever any cluster is running (e.g. an existing15/main), so:service: name=postgresql state=startedis a no-op and never starts the clusterthis role is managing — the new cluster stays down after the run.
Reload PostgreSQLhandler (state=reloaded) reloads every cluster on thehost, unexpectedly touching unrelated/production clusters.
This PR changes the Debian default to
postgresql@{{ postgresql_version }}-main,mirroring what RedHat already does (
postgresql-{{ postgresql_version }}). Start/enableand reload now affect only the cluster this role manages, which also makes side-by-side
installs (e.g. 15 and 18 on one host) behave correctly.
Changes
tasks/debian.yml: addEnsure the PostgreSQL cluster exists (Debian)usingpg_createcluster {{ postgresql_version }} mainwith acreates:guard.vars/debian.yml:postgresql_service_name→postgresql@{{ postgresql_version }}-main.Testing
(18) now creates, configures, starts the 18 cluster on its own port, and leaves
the existing cluster untouched (no cross-cluster reload).
postgresql.confexists).Notes / compatibility
equivalent to the meta-service when only one cluster exists.