Jakub Sokołowski 9eeef53f79
database: use --comand to fix creation of DBs
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2022-12-05 12:52:58 +01:00

17 lines
546 B
YAML

---
- name: 'Create user replication user'
command: >
docker exec {{ postgres_ha_cont_name }}
psql
--username={{ postgres_ha_admin_user }}
--port={{ postgres_ha_cont_port }}
--command
"DO $$
BEGIN
CREATE ROLE {{ postgres_ha_replica_user }}
WITH REPLICATION LOGIN ENCRYPTED PASSWORD '{{ postgres_ha_replica_pass }}';
EXCEPTION WHEN DUPLICATE_OBJECT THEN
RAISE NOTICE 'not creating role {{ postgres_ha_replica_user }} -- it already exists';
END
$$;"