From 9d12298a00e5ec674d6dd3a63079cdf371d76cb1 Mon Sep 17 00:00:00 2001 From: hannahms <36494235+hannahms@users.noreply.github.com> Date: Tue, 1 Aug 2023 20:00:22 -0400 Subject: [PATCH] update vars and enhance --- roles/execute_binary_upgrade/defaults/main.yml | 9 +++++++++ roles/execute_binary_upgrade/handlers/main.yml | 2 +- .../tasks/delete_old_cluster.yml | 8 ++++++++ .../tasks/execute_binary_upgrade.yml | 16 ++++++++++++---- .../tasks/setup_systemd.yml | 6 ++++-- .../tasks/upgrade_standbys.yml | 10 ++++++++++ .../tasks/upgrade_standbys_link_Debian.yml | 4 ++++ .../tasks/upgrade_standbys_link_RedHat.yml | 1 - tests/cases/execute_binary_upgrade/playbook.yml | 7 ------- tests/cases/execute_binary_upgrade/vars.json | 2 +- 10 files changed, 49 insertions(+), 16 deletions(-) diff --git a/roles/execute_binary_upgrade/defaults/main.yml b/roles/execute_binary_upgrade/defaults/main.yml index afea3c3c..acce8839 100644 --- a/roles/execute_binary_upgrade/defaults/main.yml +++ b/roles/execute_binary_upgrade/defaults/main.yml @@ -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 diff --git a/roles/execute_binary_upgrade/handlers/main.yml b/roles/execute_binary_upgrade/handlers/main.yml index 95986ac1..1048d389 100644 --- a/roles/execute_binary_upgrade/handlers/main.yml +++ b/roles/execute_binary_upgrade/handlers/main.yml @@ -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 diff --git a/roles/execute_binary_upgrade/tasks/delete_old_cluster.yml b/roles/execute_binary_upgrade/tasks/delete_old_cluster.yml index 08d0a58a..14836973 100644 --- a/roles/execute_binary_upgrade/tasks/delete_old_cluster.yml +++ b/roles/execute_binary_upgrade/tasks/delete_old_cluster.yml @@ -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' + diff --git a/roles/execute_binary_upgrade/tasks/execute_binary_upgrade.yml b/roles/execute_binary_upgrade/tasks/execute_binary_upgrade.yml index 46582850..2f7a86b1 100644 --- a/roles/execute_binary_upgrade/tasks/execute_binary_upgrade.yml +++ b/roles/execute_binary_upgrade/tasks/execute_binary_upgrade.yml @@ -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: @@ -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: diff --git a/roles/execute_binary_upgrade/tasks/setup_systemd.yml b/roles/execute_binary_upgrade/tasks/setup_systemd.yml index bed99fec..3f7baf64 100644 --- a/roles/execute_binary_upgrade/tasks/setup_systemd.yml +++ b/roles/execute_binary_upgrade/tasks/setup_systemd.yml @@ -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: @@ -25,4 +26,5 @@ regexp: "^ExecStopPost=.*" insertafter: "^\\[Service\\]$" become: true - when: ansible_os_family == 'RedHat' + when: + - ansible_os_family == 'RedHat' diff --git a/roles/execute_binary_upgrade/tasks/upgrade_standbys.yml b/roles/execute_binary_upgrade/tasks/upgrade_standbys.yml index cdd87d6d..28c799ac 100644 --- a/roles/execute_binary_upgrade/tasks/upgrade_standbys.yml +++ b/roles/execute_binary_upgrade/tasks/upgrade_standbys.yml @@ -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" diff --git a/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_Debian.yml b/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_Debian.yml index 5be79118..b42a2e34 100644 --- a/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_Debian.yml +++ b/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_Debian.yml @@ -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: @@ -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: diff --git a/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_RedHat.yml b/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_RedHat.yml index ac36486b..8621c4cc 100644 --- a/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_RedHat.yml +++ b/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_RedHat.yml @@ -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 diff --git a/tests/cases/execute_binary_upgrade/playbook.yml b/tests/cases/execute_binary_upgrade/playbook.yml index 89d1b35c..c22b4662 100644 --- a/tests/cases/execute_binary_upgrade/playbook.yml +++ b/tests/cases/execute_binary_upgrade/playbook.yml @@ -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 diff --git a/tests/cases/execute_binary_upgrade/vars.json b/tests/cases/execute_binary_upgrade/vars.json index 0ee821b6..d974aad9 100644 --- a/tests/cases/execute_binary_upgrade/vars.json +++ b/tests/cases/execute_binary_upgrade/vars.json @@ -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 }