Setup the trust for the recovery user.

This commit is contained in:
Andrea Dell'Amico 2021-04-08 14:14:21 +02:00
parent 29fe0d4da3
commit 523152d08e
1 changed files with 26 additions and 2 deletions

View File

@ -7,7 +7,7 @@
- ansible_distribution_file_variety == "Debian"
tags: [ 'postgresql', 'postgres', 'pgpool' ]
- name: PgPool II configuration
- name: PgPool II users setup
block:
- name: Add the postgres user that will manage the recovery, if not postgres
become: True
@ -34,8 +34,28 @@
- ('{{ pgpool_recovery_user }}' != 'postgres')
- pgpool_recovery_user_pwd is defined
- name: Configure the replication user permissions on deb
postgresql_pg_hba:
dest: '{{ psql_conf_dir }}/pg_hba.conf'
contype: host
users: '{{ pgpool_recovery_user }}'
address: '{{ item.0.name }}'
databases: 'all'
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
user: user={{ pgpool_recovery_user }} generate_ssh_key=yes ssh_key_bits=2048 ssh_key_file=.ssh/id_rsa ssh_key_type=rsa
user: user={{ pgpool_recovery_user }} generate_ssh_key=yes ssh_key_bits=2048 ssh_key_file=.ssh/id_rsa ssh_key_type=ed25519
- name: Remember to trust the ssh keys between the two nodes
debug:
@ -47,6 +67,10 @@
- '{{ pgpool_backends | default([]) }}'
- [ '{{ pgpool_recovery_stage1_script }}', '{{ pgpool_recovery_stage2_script }}', '{{ pgpool_remote_start_script }}' ]
tags: [ 'postgresql', 'postgres', 'pgpool', 'pgpool_user' ]
- name: PgPool II postgres setup
block:
- name: Set the postgresql configuration parameters needed by pgpool
action: configfile path={{ psql_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
with_items: '{{ psql_wal_files_conf }}'