vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on Patroni). Automating with Ansible.
https://postgresql-cluster.org
MIT License
1.64k stars 407 forks source link

pgbouncer user doesn't exist error when trying to deploy from command line #795

Open biglolka opened 3 hours ago

biglolka commented 3 hours ago

Hello @vitabaks,

I'm trying to deploy the cluster with the ansible script, but I keep getting the following error:

`fatal: [172.22.134.241]: FAILED! => {"changed": true, "cmd": ["/usr/lib/postgresql/16/bin/psql", "-p", "5432", "-U", "postgres", "-d", "postgres", "-tAXc", "CREATE FUNCTION user_search(uname TEXT) RETURNS TABLE (usename name, passwd text) AS $$ SELECT usename, passwd FROM pg_shadow WHERE usename=$1; $$ LANGUAGE sql SECURITY DEFINER; REVOKE ALL ON FUNCTION user_search(uname TEXT) FROM public; GRANT EXECUTE ON FUNCTION user_search(uname TEXT) TO pgbouncer"], "delta": "0:00:00.011840", "end": "2024-10-22 13:16:06.143323", "msg": "non-zero return code", "rc": 1, "start": "2024-10-22 13:16:06.131483", "stderr": "ERROR:  role \"pgbouncer\" does not exist", "stderr_lines": ["ERROR:  role \"pgbouncer\" does not exist"], "stdout": "CREATE FUNCTION\nREVOKE", "stdout_lines": ["CREATE FUNCTION", "REVOKE"]}`

Thanks in advance for your response!

vitabaks commented 3 hours ago

Hi @biglolka

Which version of postgresql_cluster are you using?

Make sure that you have a pgbouncer user defined in the postgresql_users variable as here https://github.com/vitabaks/postgresql_cluster/blob/2.0.0/automation/vars/main.yml#L186