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 (Upgrade): Delegate maintenance mode tasks to 'balancers' group #699

Merged
merged 2 commits into from
Jul 16, 2024
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
2 changes: 1 addition & 1 deletion roles/haproxy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

- name: Gather facts for hosts postres_cluster
- name: Gather facts from postgres_cluster hosts
ansible.builtin.setup:
delegate_to: "{{ item }}"
delegate_facts: true
Expand Down
10 changes: 10 additions & 0 deletions roles/upgrade/tasks/maintenance_disable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,30 @@
dest: /etc/haproxy/haproxy.cfg
owner: haproxy
group: haproxy
delegate_to: "{{ item }}"
loop: "{{ groups.balancers | default([]) | list }}"
run_once: true

- name: Reload haproxy service
ansible.builtin.systemd:
name: haproxy
state: reloaded
delegate_to: "{{ item }}"
loop: "{{ groups.balancers | default([]) | list }}"
run_once: true

- name: Start confd service
ansible.builtin.service:
name: confd
state: started
delegate_to: "{{ item }}"
loop: "{{ groups.balancers | default([]) | list }}"
run_once: true
become: true
become_user: root
ignore_errors: true # show the error and continue the playbook execution
when:
- groups.balancers | default([]) | length > 0
- with_haproxy_load_balancing | bool
- pgbouncer_install | bool
- pgbouncer_pool_pause | bool
Expand Down
17 changes: 17 additions & 0 deletions roles/upgrade/tasks/maintenance_enable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@
# Temporarily disable http-checks in order to keep database connections after stopping the Patroni service
# and then pause the pgbouncer pools.
- block:
- name: Gather facts from balancers
ansible.builtin.setup:
delegate_to: "{{ item }}"
delegate_facts: true
loop: "{{ groups.balancers | default([]) | list }}"
run_once: true

- name: Stop confd service
ansible.builtin.service:
name: confd
state: stopped
delegate_to: "{{ item }}"
loop: "{{ groups.balancers | default([]) | list }}"
run_once: true
when: dcs_type == "etcd"

- name: Update haproxy conf file (disable http-checks)
Expand All @@ -28,14 +38,21 @@
dest: /etc/haproxy/haproxy.cfg
owner: haproxy
group: haproxy
delegate_to: "{{ item }}"
loop: "{{ groups.balancers | default([]) | list }}"
run_once: true

- name: Reload haproxy service
ansible.builtin.systemd:
name: haproxy
state: reloaded
delegate_to: "{{ item }}"
loop: "{{ groups.balancers | default([]) | list }}"
run_once: true
become: true
become_user: root
when:
- groups.balancers | default([]) | length > 0
- with_haproxy_load_balancing | bool
- pgbouncer_install | bool
- pgbouncer_pool_pause | bool
Expand Down
6 changes: 6 additions & 0 deletions roles/upgrade/tasks/update_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
dest: "{{ patroni_config_file }}.bkp"
remote_src: true

# https://github.com/vitabaks/postgresql_cluster/issues/666
- name: Remove patroni.dynamic.json file
ansible.builtin.file:
path: "{{ pg_old_datadir }}/patroni.dynamic.json"
state: absent

# Update the directory path to a new version of PostgresSQL
- name: "Edit patroni.yml | update parameters: data_dir, bin_dir, config_dir"
ansible.builtin.replace:
Expand Down
Loading