Skip to content

Commit 1887ffa

Browse files
committed
update pg_hba.conf tasks
Allow execution of the "generate pg_hba.conf on Replica" task for RedHat-based systems, if the "postgresql_exists" variable is "true". Allow to perform pg_hba tasks before executing the add_pgnode.yml playbook for cluster scaling: ansible-playbook deploy_pgcluster.yml --tags pg_hba Reduced the number of code.
1 parent 22c7c0a commit 1887ffa

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

roles/patroni/tasks/main.yml

+6-12
Original file line numberDiff line numberDiff line change
@@ -820,24 +820,17 @@
820820
tags: patroni, patroni_start_master, point_in_time_recovery
821821

822822
- block: # pg_hba (using a templates/pg_hba.conf.j2)
823-
- name: Prepare PostgreSQL | generate pg_hba.conf on Master
823+
- name: Prepare PostgreSQL | generate pg_hba.conf
824824
template:
825825
src: templates/pg_hba.conf.j2
826826
dest: "{{ postgresql_conf_dir }}/pg_hba.conf"
827827
owner: postgres
828828
group: postgres
829829
mode: 0640
830-
when: is_master == "true"
831-
832-
- name: Prepare PostgreSQL | generate pg_hba.conf on Replica
833-
template:
834-
src: templates/pg_hba.conf.j2
835-
dest: "{{ postgresql_conf_dir }}/pg_hba.conf"
836-
owner: postgres
837-
group: postgres
838-
mode: 0640
839-
when: is_master != "true" and
840-
postgresql_conf_dir != postgresql_data_dir
830+
register: generate_pg_hba
831+
when: is_master == "true" or
832+
((is_master != "true" and postgresql_conf_dir != postgresql_data_dir)
833+
or postgresql_exists == "true")
841834

842835
- name: Prepare PostgreSQL | reload for apply the pg_hba.conf
843836
become: true
@@ -846,6 +839,7 @@
846839
register: psql_reload_result
847840
changed_when: psql_reload_result.rc == 0
848841
failed_when: false # exec pg_reload_conf on all running postgres (to re-run with --tag pg_hba).
842+
when: generate_pg_hba is changed
849843
when: existing_pgcluster is not defined or not existing_pgcluster|bool
850844
tags: patroni, pg_hba, pg_hba_generate
851845

0 commit comments

Comments
 (0)