vitabaks / postgresql_cluster

Automated database platform for PostgreSQL® A modern, open-source alternative to cloud-managed databases.
https://postgresql-cluster.org
MIT License
1.83k stars 418 forks source link

pgpass: run the task as the root user #791

Closed vitabaks closed 1 month ago

vitabaks commented 1 month ago

Issue: https://github.com/vitabaks/postgresql_cluster/issues/790

This PR resolves the issue where the Ansible task failed to configure the .pgpass file due to a “Permission denied” error when specifying a different path in the postgresql_home_dir variable.

Fixed:

TASK [pgpass: Configure a password file (/data/var/lib/postgresql/-pgpass)] *****************************************************
task path: /home/infraoperator/postgres_prod/postgresql_cluster/roles/pgpass/tasks/main.yml:3
fatal: [192.168.7.31]: FAILED! => {
"msg": "Failed to get information on remote file (/data/var/lib/postgresql/.pgpass): Permission denied"
}

The task now uses become_user: root and adjusts permissions to ensure proper access for the postgres user.