diff --git a/tasks/postgres_pgpool.yml b/tasks/postgres_pgpool.yml index 8adce70..beb41be 100644 --- a/tasks/postgres_pgpool.yml +++ b/tasks/postgres_pgpool.yml @@ -34,7 +34,7 @@ - ('{{ pgpool_recovery_user }}' != 'postgres') - pgpool_recovery_user_pwd is defined - - name: Configure the replication user permissions on deb + - name: Configure the global replication user permissions on deb when no password has been defined postgresql_pg_hba: dest: '{{ psql_conf_dir }}/pg_hba.conf' contype: host @@ -52,6 +52,24 @@ - pgpool_recovery_user_pwd is not defined notify: Reload postgresql + - name: Configure the replication user permissions for the replication DB on deb when no password has been defined + postgresql_pg_hba: + dest: '{{ psql_conf_dir }}/pg_hba.conf' + contype: host + users: '{{ pgpool_recovery_user }}' + address: '{{ item.1 }}' + databases: 'replication' + method: 'trust' + state: present + with_subelements: + - '{{ psql_db_data | default([]) }}' + - allowed_hosts + when: + - psql_db_data is defined + - item.1 is defined + - pgpool_recovery_user_pwd is not defined + notify: Reload postgresql + - meta: flush_handlers - name: Create the ssh keys for the recovery user diff --git a/templates/pgpool_recovery_stage_1.j2 b/templates/pgpool_recovery_stage_1.j2 index 44c5ed6..7182d57 100644 --- a/templates/pgpool_recovery_stage_1.j2 +++ b/templates/pgpool_recovery_stage_1.j2 @@ -39,7 +39,7 @@ logger "pgpool_recovery_1: touched the backup_in_progress file" # Perform a backup of the database. ssh -T $RECOVERY_TARGET \ - "pg_basebackup -h $MASTER_HOST -D $RECOVERY_DATA" + "pg_basebackup -h $MASTER_HOST -p {{ psql_db_port }} -D $RECOVERY_DATA" logger "pgpool_recovery_1: backup of the database from $MASTER_HOST to $RECOVERY_TARGET"