Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Skip creating DB users and functions in Standby Cluster leader #533

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion roles/pgbouncer/config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@
'; done
args:
executable: /bin/bash
when: pgbouncer_auth_user|bool and is_master|bool
when:
- pgbouncer_auth_user | bool
- (is_master | bool and patroni_standby_cluster.host | default('') | length < 1) # do not perform on the Standby Cluster leader
tags: pgbouncer, pgbouncer_conf, pgbouncer_auth_query

...
9 changes: 6 additions & 3 deletions roles/postgresql-users/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
loop: "{{ postgresql_users | flatten(1) }}"
loop_control:
label: "{{ item.name }}"
when: postgresql_users is defined and postgresql_users | length > 0
when:
- postgresql_users | default('') | length > 0
- item.password | default('') | length > 0 # Ensure the password is not empty
- patroni_standby_cluster.host | default('') | length < 1 # do not perform on the Standby Cluster leader
tags: postgresql_users

- name: Grant roles to users
Expand All @@ -35,9 +38,9 @@
loop_control:
label: "{{ item.name }}"
when:
- postgresql_users is defined
- postgresql_users | length > 0
- postgresql_users | default('') | length > 0
- item.role | default('') | length > 0
- patroni_standby_cluster.host | default('') | length < 1 # do not perform on the Standby Cluster leader
tags: postgresql_users

...