diff --git a/roles/keepalived/handlers/main.yml b/roles/keepalived/handlers/main.yml index 187306cf2..32d6c081e 100644 --- a/roles/keepalived/handlers/main.yml +++ b/roles/keepalived/handlers/main.yml @@ -8,13 +8,26 @@ state: restarted listen: "restart keepalived" +# This task checks the cluster VIP's availability, selecting the appropriate port: +# - during maintenance, it targets the database through PgBouncer or directly. +# - otherwise, it defaults to SSH, applicable during deployment when the database is not yet available. - name: Wait for the cluster ip address (VIP) "{{ cluster_vip }}" is running ansible.builtin.wait_for: host: "{{ cluster_vip }}" - port: "{{ ansible_ssh_port | default(22) }}" + port: "{{ target_port }}" state: started - timeout: 60 + timeout: 15 # max wait time: 30 seconds delay: 2 + vars: + target_port: >- + {{ + (postgresql_cluster_maintenance | default(false) | bool) | + ternary( + pgbouncer_listen_port if pgbouncer_install | bool else postgresql_port, + ansible_ssh_port | default(22) + ) + }} + ignore_errors: true # show the error and continue the playbook execution listen: "restart keepalived" ... diff --git a/roles/upgrade/tasks/pre_checks.yml b/roles/upgrade/tasks/pre_checks.yml index 229a5b9a5..18e80e8a1 100644 --- a/roles/upgrade/tasks/pre_checks.yml +++ b/roles/upgrade/tasks/pre_checks.yml @@ -394,14 +394,11 @@ - name: Make sure that the cluster ip address (VIP) "{{ cluster_vip }}" is running ansible.builtin.wait_for: host: "{{ cluster_vip }}" - port: "{{ target_port }}" + port: "{{ pgbouncer_listen_port if pgbouncer_install | bool else postgresql_port }}" state: started - timeout: 3 + timeout: 15 # max wait time: 30 seconds delay: 2 - vars: - target_port: >- - {{ pgbouncer_listen_port if pgbouncer_install | bool - else (ansible_ssh_port | default(22)) }} + ignore_errors: true # show the error and continue the playbook execution when: - cluster_vip | length > 0 diff --git a/roles/vip-manager/handlers/main.yml b/roles/vip-manager/handlers/main.yml index e80d6f7a6..3e4b8531e 100644 --- a/roles/vip-manager/handlers/main.yml +++ b/roles/vip-manager/handlers/main.yml @@ -11,10 +11,11 @@ - name: Wait for the cluster ip address (VIP) "{{ cluster_vip }}" is running ansible.builtin.wait_for: host: "{{ cluster_vip }}" - port: "{{ ansible_ssh_port | default(22) }}" + port: "{{ pgbouncer_listen_port if pgbouncer_install | bool else postgresql_port }}" state: started - timeout: 60 + timeout: 15 # max wait time: 30 seconds delay: 2 + ignore_errors: true # show the error and continue the playbook execution listen: "restart vip-manager" ...