add hack when multiple interfaces or multiple default gw exists

This commit is contained in:
ace 2023-09-26 16:51:20 +03:00
parent bbfba812c0
commit e5195e0592
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
2 changed files with 12 additions and 2 deletions

View File

@ -32,6 +32,9 @@ patroni_ssl: true
patroni_ssl_path: "/etc/patroni/ssl" patroni_ssl_path: "/etc/patroni/ssl"
patroni_self_signed_cert: false patroni_self_signed_cert: false
patroni_self_signed_cert_name: "cert" patroni_self_signed_cert_name: "cert"
patroni_cacert_multiple_default_gw_workaround: false
patroni_cacert_force_append_ips: []
patroni_cacert_force_append_names: []
## DCS options. Consul or Etcd ## DCS options. Consul or Etcd
patroni_dcs_exists: false patroni_dcs_exists: false

View File

@ -83,7 +83,14 @@
- name: Generate Patroni subject_alt_ips from default ipv4 address - name: Generate Patroni subject_alt_ips from default ipv4 address
set_fact: set_fact:
patroni_server_subject_alt_ips: "{{ groups[patroni_play_group] | default([]) | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | map('regex_replace', '^', 'IP:') | list }}" patroni_server_subject_alt_ips: "{{ groups[patroni_play_group] | default([]) | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | map('regex_replace', '^', 'IP:') | list }}"
when: hostvars[inventory_hostname]['ansible_default_ipv4']['address'] is defined when:
- hostvars[inventory_hostname]['ansible_default_ipv4']['address'] is defined
- not patroni_cacert_multiple_default_gw_workaround
- name: Generate Patroni subject_alt_ips from ansible_all_ipv4_addresses
set_fact:
patroni_server_subject_alt_ips_all_ipv4: "{{ groups[patroni_play_group] | default([]) | map('extract', hostvars, ['ansible_all_ipv4_addresses']) | flatten | map('regex_replace', '^', 'IP:') | list }}"
when: hostvars[inventory_hostname]['ansible_all_ipv4_addresses'] is defined
- name: Generate Patroni subject_alt_names - name: Generate Patroni subject_alt_names
set_fact: set_fact:
@ -94,7 +101,7 @@
path: "{{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.csr" path: "{{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.csr"
privatekey_path: "{{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.key" privatekey_path: "{{ patroni_ssl_path }}/{{ patroni_self_signed_cert_name }}.key"
common_name: "{{ patroni_self_signed_cert_name }}" common_name: "{{ patroni_self_signed_cert_name }}"
subject_alt_name: "{{ patroni_server_subject_alt_ips | default([]) + patroni_server_subject_alt_names | default([]) + patroni_agent_subject_alt_ips | default([]) + patroni_agent_subject_alt_names | default([]) + patroni_server_subject_alt_ips_from_ansible_host | default([]) + patroni_agent_subject_alt_ips_from_ansible_host | default([]) }}" subject_alt_name: "{{ patroni_server_subject_alt_ips | default([]) + patroni_server_subject_alt_names | default([]) + patroni_agent_subject_alt_ips | default([]) + patroni_agent_subject_alt_names | default([]) + patroni_server_subject_alt_ips_from_ansible_host | default([]) + patroni_server_subject_alt_ips_all_ipv4 | default([]) + patroni_agent_subject_alt_ips_from_ansible_host | default([]) }}"
owner: postgres owner: postgres
group: postgres group: postgres
register: patroni_csr register: patroni_csr