infra-role-postgres-ha/tasks/users.yml

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
$$;"