From cb9db73ce7dd894f293cdf4ad3bc84ed6e73b6e8 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com> Date: Mon, 4 Dec 2023 18:58:06 +0300 Subject: [PATCH] Do not use a proxy when accessing the Patroni API (#521) --- config_pgcluster.yml | 2 ++ pg_upgrade.yml | 2 ++ roles/patroni/tasks/custom_wal_dir.yml | 4 ++++ roles/patroni/tasks/main.yml | 4 ++++ roles/update/tasks/extensions.yml | 2 ++ roles/update/tasks/pre_checks.yml | 2 +- roles/update/tasks/start_services.yml | 2 ++ roles/update/tasks/start_traffic.yml | 2 ++ roles/update/tasks/stop_traffic.yml | 2 ++ roles/update/tasks/switchover.yml | 2 ++ roles/upgrade/tasks/rollback.yml | 6 ++++++ roles/upgrade/tasks/start_services.yml | 4 ++++ update_pgcluster.yml | 2 ++ 13 files changed, 35 insertions(+), 1 deletion(-) diff --git a/config_pgcluster.yml b/config_pgcluster.yml index b2d08c7f2..a1ef4a80f 100644 --- a/config_pgcluster.yml +++ b/config_pgcluster.yml @@ -24,6 +24,8 @@ changed_when: false failed_when: false check_mode: false + environment: + no_proxy: "{{ inventory_hostname }}" # Stop, if Patroni is unavailable - name: The Patroni cluster is unhealthy diff --git a/pg_upgrade.yml b/pg_upgrade.yml index 86068b1dd..bcd2dc23e 100644 --- a/pg_upgrade.yml +++ b/pg_upgrade.yml @@ -21,6 +21,8 @@ register: patroni_leader_result changed_when: false failed_when: false + environment: + no_proxy: "{{ inventory_hostname }}" # Stop, if Patroni is unavailable - name: The Patroni cluster is unhealthy diff --git a/roles/patroni/tasks/custom_wal_dir.yml b/roles/patroni/tasks/custom_wal_dir.yml index de7853ffa..d1ae359a5 100644 --- a/roles/patroni/tasks/custom_wal_dir.yml +++ b/roles/patroni/tasks/custom_wal_dir.yml @@ -113,6 +113,8 @@ until: patroni_result.status == 200 retries: 120 delay: 10 + environment: + no_proxy: "{{ inventory_hostname }}" when: is_master | bool and not ansible_check_mode - name: Start patroni service on the Replica @@ -141,6 +143,8 @@ until: patroni_result.status == 200 retries: 120 delay: 10 + environment: + no_proxy: "{{ inventory_hostname }}" when: not is_master | bool and not ansible_check_mode - name: "Remove {{ pg_wal_dir }}_old directory" diff --git a/roles/patroni/tasks/main.yml b/roles/patroni/tasks/main.yml index 2a3da63dd..f936129eb 100644 --- a/roles/patroni/tasks/main.yml +++ b/roles/patroni/tasks/main.yml @@ -852,6 +852,8 @@ until: result.status == 200 retries: 10 delay: 2 + environment: + no_proxy: "{{ inventory_hostname }}" when: - (patroni_standby_cluster.host is not defined or patroni_standby_cluster.host | length < 1) - not ansible_check_mode @@ -1000,6 +1002,8 @@ until: replica_result.status == 200 retries: 1200 # timeout 10 hours delay: 30 + environment: + no_proxy: "{{ inventory_hostname }}" when: not ansible_check_mode when: not is_master | bool tags: patroni, patroni_start_replica, point_in_time_recovery diff --git a/roles/update/tasks/extensions.yml b/roles/update/tasks/extensions.yml index 3293507d2..9339f0d3b 100644 --- a/roles/update/tasks/extensions.yml +++ b/roles/update/tasks/extensions.yml @@ -6,6 +6,8 @@ register: patroni_leader_result changed_when: false failed_when: false + environment: + no_proxy: "{{ inventory_hostname }}" - name: Get a list of databases ansible.builtin.command: >- diff --git a/roles/update/tasks/pre_checks.yml b/roles/update/tasks/pre_checks.yml index 561c2d9d5..44cf0ad08 100644 --- a/roles/update/tasks/pre_checks.yml +++ b/roles/update/tasks/pre_checks.yml @@ -1,6 +1,6 @@ --- - name: '[Pre-Check] (ALL) Test PostgreSQL DB Access' - ansible.builtin.command: > + ansible.builtin.command: >- psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc 'select 1' changed_when: false diff --git a/roles/update/tasks/start_services.yml b/roles/update/tasks/start_services.yml index 5635fd920..26dfd643a 100644 --- a/roles/update/tasks/start_services.yml +++ b/roles/update/tasks/start_services.yml @@ -22,6 +22,8 @@ until: patroni_replica_result.status == 200 retries: 300 delay: 2 + environment: + no_proxy: "{{ inventory_hostname }}" - name: Check PostgreSQL is started and accepting connections become: true diff --git a/roles/update/tasks/start_traffic.yml b/roles/update/tasks/start_traffic.yml index 3a0c9ae3e..4a4cdd372 100644 --- a/roles/update/tasks/start_traffic.yml +++ b/roles/update/tasks/start_traffic.yml @@ -26,4 +26,6 @@ until: patroni_replica_result.status == 200 retries: 30 delay: 2 + environment: + no_proxy: "{{ inventory_hostname }}" ... diff --git a/roles/update/tasks/stop_traffic.yml b/roles/update/tasks/stop_traffic.yml index 629077409..aea40853e 100644 --- a/roles/update/tasks/stop_traffic.yml +++ b/roles/update/tasks/stop_traffic.yml @@ -26,6 +26,8 @@ until: patroni_replica_result.status == 503 retries: 30 delay: 2 + environment: + no_proxy: "{{ inventory_hostname }}" - name: Wait for active transactions to complete become: true diff --git a/roles/update/tasks/switchover.yml b/roles/update/tasks/switchover.yml index c32f8d35c..95f9583c1 100644 --- a/roles/update/tasks/switchover.yml +++ b/roles/update/tasks/switchover.yml @@ -23,4 +23,6 @@ until: patroni_replica_result.status == 200 retries: 300 delay: 2 + environment: + no_proxy: "{{ inventory_hostname }}" ... diff --git a/roles/upgrade/tasks/rollback.yml b/roles/upgrade/tasks/rollback.yml index 3aa6f78b9..0adbc01a5 100644 --- a/roles/upgrade/tasks/rollback.yml +++ b/roles/upgrade/tasks/rollback.yml @@ -20,6 +20,8 @@ register: patroni_cluster_result failed_when: false changed_when: false + environment: + no_proxy: "{{ inventory_hostname }}" when: - inventory_hostname in groups['primary'] @@ -133,6 +135,8 @@ until: patroni_leader_result.status == 200 retries: "{{ (pg_start_stop_timeout | int) // 2 }}" delay: 2 + environment: + no_proxy: "{{ inventory_hostname }}" when: - inventory_hostname in groups['primary'] @@ -163,6 +167,8 @@ until: patroni_replica_result.status == 200 retries: "{{ (pg_start_stop_timeout | int) // 2 }}" delay: 2 + environment: + no_proxy: "{{ inventory_hostname }}" when: - inventory_hostname in groups['secondary'] diff --git a/roles/upgrade/tasks/start_services.yml b/roles/upgrade/tasks/start_services.yml index 71c9507c0..1e635dec1 100644 --- a/roles/upgrade/tasks/start_services.yml +++ b/roles/upgrade/tasks/start_services.yml @@ -27,6 +27,8 @@ until: patroni_leader_result.status == 200 retries: "{{ (pg_start_stop_timeout | int) // 2 }}" delay: 2 + environment: + no_proxy: "{{ inventory_hostname }}" when: - inventory_hostname in groups['primary'] @@ -65,6 +67,8 @@ until: patroni_replica_result.status == 200 retries: "{{ (pg_start_stop_timeout | int) // 2 }}" delay: 2 + environment: + no_proxy: "{{ inventory_hostname }}" when: - inventory_hostname in groups['secondary'] diff --git a/update_pgcluster.yml b/update_pgcluster.yml index 58bee2d75..9c5cc92bf 100644 --- a/update_pgcluster.yml +++ b/update_pgcluster.yml @@ -17,6 +17,8 @@ register: patroni_leader_result changed_when: false failed_when: false + environment: + no_proxy: "{{ inventory_hostname }}" tags: always - name: '[Prepare] Add host to group "primary" (in-memory inventory)'