Skip to content

Commit e4fa721

Browse files
committed
fix: set data_directory to canonical path to resolve pgBackRest [058]
pgBackRest stanza-create compares the live cluster's data_directory against the DataDir stored in pg_control. initdb resolves symlinks internally so pg_control stores /data/pgdata, but postgresql.conf explicitly set data_directory to /var/lib/postgresql/data (the symlink), causing a path mismatch and [058] error on every enable attempt. Patch data_directory to /data/pgdata immediately after deploying the postgresql.conf template, scoped to the debpkg_mode/nixpkg_mode block where the /data volume and symlink are always present. Docker images and Nix test environments are unaffected as they do not use this Ansible path.
1 parent 3075114 commit e4fa721

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

ansible/tasks/setup-postgres.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@
167167
loop_control:
168168
loop_var: 'pg_config_item'
169169

170+
- name: Set data_directory to canonical path on data volume
171+
ansible.builtin.lineinfile:
172+
path: '/etc/postgresql/postgresql.conf'
173+
regexp: "^data_directory = '/var/lib/postgresql/data'"
174+
line: "data_directory = '/data/pgdata'"
175+
170176
- name: Move read-replica.conf file to /etc/postgresql-custom/read-replica.conf
171177
ansible.builtin.copy:
172178
dest: '/etc/postgresql-custom/read-replica.conf'

0 commit comments

Comments
 (0)