|
146 | 146 | when: not with_haproxy_load_balancing | bool and not pgbouncer_install | bool |
147 | 147 | ignore_errors: true |
148 | 148 | vars: |
149 | | - public_haproxy_ip_addresses: "{{ groups['balancers'] | default([]) | map('extract', hostvars, 'ansible_ssh_host') | join(',') }}" |
150 | | - public_postgres_ip_addresses: "{{ groups['postgres_cluster'] | default([]) | map('extract', hostvars, 'ansible_ssh_host') | join(',') }}" |
151 | | - haproxy_ip_addresses: "{{ groups['balancers'] | default([]) | map('extract', hostvars) | map(attribute='haproxy_bind_address', default=bind_address) | join(',') }}" |
152 | | - postgres_ip_addresses: "{{ groups['postgres_cluster'] | default([]) | map('extract', hostvars) | map(attribute='patroni_bind_address', default=bind_address) | join(',') }}" |
| 149 | + public_haproxy_ip_addresses: "{{ groups['balancers'] | default([]) | map('extract', hostvars, 'ansible_ssh_host') | join(', ') }}" |
| 150 | + public_postgres_ip_addresses: "{{ groups['postgres_cluster'] | default([]) | map('extract', hostvars, 'ansible_ssh_host') | join(', ') }}" |
| 151 | + haproxy_ip_addresses: >- |
| 152 | + {{ |
| 153 | + (groups['balancers'] | default([]) | map('extract', hostvars, 'haproxy_bind_address') | map('default', None, True) | list) |
| 154 | + | zip(groups['balancers'] | default([]) | map('extract', hostvars, 'bind_address') | map('default', None, True) | list) |
| 155 | + | map('list') | map('select', 'truthy') | map('first') | unique | join(', ') |
| 156 | + }} |
| 157 | + postgres_ip_addresses: >- |
| 158 | + {{ |
| 159 | + (groups['postgres_cluster'] | default([]) | map('extract', hostvars, 'patroni_bind_address') | map('default', None, True) | list) |
| 160 | + | zip(groups['postgres_cluster'] | default([]) | map('extract', hostvars, 'bind_address') | map('default', None, True) | list) |
| 161 | + | map('list') | map('select', 'truthy') | map('first') | unique | join(', ') |
| 162 | + }} |
153 | 163 | superuser_username: "{{ patroni_superuser_username }}" |
154 | 164 | superuser_password: "{{ '********' if mask_password | default(false) | bool else patroni_superuser_password }}" |
155 | | - libpq_postgres_host_port: "{{ postgres_ip_addresses.split(',') | map('regex_replace', '$', ':' + postgresql_port | string) | join(',') }}" |
| 165 | + libpq_postgres_host_port: "{{ postgres_ip_addresses.split(',') | map('regex_replace', '$', ':' + postgresql_port | string) | join(', ') }}" |
156 | 166 | libpq_load_balance: "{{ '&load_balance_hosts=random' if postgresql_version | int >= 16 else '' }}" |
157 | 167 | when: |
158 | 168 | - (cluster_vip is not defined or cluster_vip | length < 1) |
|
0 commit comments