blob: dd2cd842508fe9b8a8f1769a52b93bc09b976ee6 [file]
---
- block:
- name: Obtain pgmaster IP if not provided
set_fact:
pgmaster_ip: "{{ hostvars[groups['dc-1-pgmaster'][0]][interface_name].ipv4.address }}"
when: pgmaster_ip is not defined
- name: Obtain pgstandby IP if not provided
set_fact:
pgstandby_ip: "{{ hostvars[groups['dc-1-pgstandby'][0]][interface_name].ipv4.address }}"
when: pgstandby_ip is not defined
when: "{{ groups['dc-2-pgmaster'] is defined and groups['dc-2-pgstandby'] is defined and inventory_hostname in groups['dc-2'] }}"
- block:
- name: Obtain pgmaster IP if not provided
set_fact:
pgmaster_ip: "{{ hostvars[groups['dc-1-pgmaster'][0]][interface_name].ipv4.address }}"
when: pgmaster_ip is not defined
- name: Obtain pgstandby IP if not provided
set_fact:
pgstandby_ip: "{{ hostvars[groups['dc-1-pgstandby'][0]][interface_name].ipv4.address }}"
when: pgstandby_ip is not defined
when: "{{ groups['dc-1-pgmaster'] is defined and groups['dc-1-pgstandby'] is defined and inventory_hostname in groups['dc-1'] }}"
- name: Set pgmaster_ip in cache
cache:
key: pgmaster_ip
value: '{{ pgmaster_ip }}'
- name: Set pgstandby_ip in cache
cache:
key: pgstandby_ip
value: '{{ pgstandby_ip }}'