Skip to content

bug(ansible): postgresql role skips cluster init when package pre-installed, install hangs 300s #5603

@mrveiss

Description

@mrveiss

Bug

When postgresql-16 is already installed (from a prior failed run or manual install) but no cluster was initialized, the postgresql Ansible role:

  1. Skips all installation tasks (when: _pg_installed.rc != 0 is false)
  2. Enables and starts postgresql.service (the Ubuntu meta-wrapper that runs /bin/true)
  3. Waits 60×5s=300s for the socket at /var/run/postgresql/.s.PGSQL.5432 that never appears

Root Cause

pg_createcluster 16 main was never run, so /var/lib/postgresql/16/main/ doesn't exist. The meta service starts successfully (/bin/true) but no actual PostgreSQL process ever listens.

Fix

Added two tasks to install.yml between package install and service enable:

  • Stat {{ postgresql_data_dir }}/PG_VERSION
  • Initialize cluster via pg_createcluster {{ postgresql_version }} main when missing

Reproduction

Install PostgreSQL 16, drop or never initialize the cluster, then run deploy-slm-manager.yml.

Impact

install.sh hangs for 5 minutes then fails at step 4 of 7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions