Skip to content

Commit

Permalink
update vars and enhance
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahms authored and vibhorkumar123 committed Aug 8, 2023
1 parent 669c5a3 commit 9d12298
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 16 deletions.
9 changes: 9 additions & 0 deletions roles/execute_binary_upgrade/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ pg_upgrade_additional_params: ""
# setting to true will recreate these slots
use_replication_slots: true

# if using copy method, the standbys will be recreated from scratch.
# include replication parameters
pg_replication_user: "repuser"
pg_replication_user_password: ""
synchronous_standby_names: ""
standby_quorum_type: "any"
pg_basebackup: "{{ new_pg_bin_path }}/pg_basebackup -Fp -R -l standby --checkpoint=fast --wal-method=stream"
pg_basebackup_options: ""

# setting validate_only to true allows you to validate setup on an existing node
# use_validation flag applies to deployment configuration and validation after setup
validate_only: false
Expand Down
2 changes: 1 addition & 1 deletion roles/execute_binary_upgrade/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Stop the new PG service
ansible.builtin.systemd:
name: "{{ pg_service }}"
name: "{{ new_pg_service }}"
state: stopped

- name: Drop the default new EPAS debian database
Expand Down
8 changes: 8 additions & 0 deletions roles/execute_binary_upgrade/tasks/delete_old_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@
loop:
- "{{ old_pg_bin_path | dirname }}"
- "{{ old_pg_data | dirname }}"

- name: Remove old configuration directory on Debian
ansible.builtin.file:
path: "{{ old_pg_config_dir }}"
state: absent
become: true
when: ansible_os_family == 'Debian'

16 changes: 12 additions & 4 deletions roles/execute_binary_upgrade/tasks/execute_binary_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,10 @@
register: pg_controldata_check
become: true
become_user: "{{ pg_owner }}"
no_log: "{{ disable_logging }}"
when:
- _standby_private_ip|length > 0

- name: Debug
ansible.builtin.debug:
var: pg_controldata_check

- name: Check that all latest checkpoint locations are the same
ansible.builtin.assert:
that:
Expand Down Expand Up @@ -95,6 +92,17 @@
- name: Execute pg_upgrade
ansible.builtin.include_tasks: pg_upgrade.yml

- name: Enable and start systemd service on primary if no standbys are present
ansible.builtin.systemd:
name: "{{ new_pg_service }}"
daemon_reload: true
state: started
enabled: true
become: true
when:
- "'primary' in group_names"
- _standby_private_ip|length < 1

- name: Include upgrade_standbys when not use_link_method
ansible.builtin.include_tasks: upgrade_standbys.yml
when:
Expand Down
6 changes: 4 additions & 2 deletions roles/execute_binary_upgrade/tasks/setup_systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
owner: root
group: root
become: true
when: ansible_os_family == 'RedHat'
when:
- ansible_os_family == 'RedHat'

- name: Update new systemd unit file
edb_devops.edb_postgres.linesinfile:
Expand All @@ -25,4 +26,5 @@
regexp: "^ExecStopPost=.*"
insertafter: "^\\[Service\\]$"
become: true
when: ansible_os_family == 'RedHat'
when:
- ansible_os_family == 'RedHat'
10 changes: 10 additions & 0 deletions roles/execute_binary_upgrade/tasks/upgrade_standbys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
pg_version: "{{ new_pg_version }}"
pg_service: "{{ new_pg_service }}"
pg_data: "{{ new_pg_data }}"
pg_default_data: "{{ new_pg_default_data }}"
pg_wal: "{{ new_pg_wal }}"
pg_systemd_global_unit_file: "{{ new_pg_systemd_global_unit_file | default('') }}"
pg_bin_path: "{{ new_pg_bin_path }}"
pg_initdb: "{{ new_pg_initdb }}"
pg_initdb_options: "{{ new_pg_initdb_options }}"
pg_port: "{{ new_pg_port }}"
pg_basebackup: "{{ pg_basebackup }}"
pg_basebackup_options: "{{ pg_basebackup_options }}"
use_validation: false
no_log: "{{ disable_logging }}"
when: "'standby' in group_names"

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# generate ssh keys to execute rsync commands
- name: Include the SSH keys generation tasks
ansible.builtin.include_tasks: generate_ssh_keys.yml
no_log: "{{ disable_logging }}"

- name: Include the SSH keys exchange tasks
ansible.builtin.include_tasks: exchange_ssh_keys.yml
no_log: "{{ disable_logging }}"

- name: Install rsync on primary
ansible.builtin.package:
Expand Down Expand Up @@ -38,6 +40,8 @@
mode: "0700"
state: directory
become: true
when:
- "'standby' in group_names"

- name: Save postgresql.auto.conf to tmp/pgupgrade
ansible.builtin.copy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
loop_control:
loop_var: standby_node
when: "'primary' in group_names"
register: rsync_output

# run rsync command for pg_wal directory if new_pg_data not in new_pg_wal
- name: Run rsync command for pg_wal
Expand Down
7 changes: 0 additions & 7 deletions tests/cases/execute_binary_upgrade/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@
- name: Initialize the user defined variables
ansible.builtin.set_fact:
disable_logging: false
pg_shared_libraries_list:
- "$libdir/dbms_pipe"
- "$libdir/edb_gen"
- "$libdir/dbms_aq"
- "$libdir/sql-profiler"
- "$libdir/index_advisor"
- "$libdir/pg_stat_statements"

roles:
- role: setup_repo
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/execute_binary_upgrade/vars.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"use_hostname": false,
"pg_ssl": false,
"use_link_method": true,
"use_link_method": false,
"old_pg_version": 13,
"new_pg_version": 15
}

0 comments on commit 9d12298

Please sign in to comment.