2018-10-03 22:09:33 +08:00
|
|
|
---
|
2020-03-23 23:14:29 +08:00
|
|
|
- name: set_fact _monitor_addresses to monitor_address_block ipv4
|
2018-10-03 22:09:33 +08:00
|
|
|
set_fact:
|
2021-03-03 22:43:50 +08:00
|
|
|
_monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['ansible_facts']['all_ipv4_addresses'] | ips_in_ranges(hostvars[item]['monitor_address_block'].split(',')) | first }] }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ groups.get(mon_group_name, []) }}"
|
2018-10-03 22:09:33 +08:00
|
|
|
when:
|
|
|
|
- "item not in _monitor_addresses | default([]) | selectattr('name', 'defined') | map(attribute='name') | list"
|
|
|
|
- hostvars[item]['monitor_address_block'] is defined
|
|
|
|
- hostvars[item]['monitor_address_block'] != 'subnet'
|
2019-04-06 03:04:45 +08:00
|
|
|
- ip_version == 'ipv4'
|
|
|
|
|
2020-03-23 23:14:29 +08:00
|
|
|
- name: set_fact _monitor_addresses to monitor_address_block ipv6
|
2019-04-06 03:04:45 +08:00
|
|
|
set_fact:
|
2021-03-03 22:43:50 +08:00
|
|
|
_monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['ansible_facts']['all_ipv6_addresses'] | ips_in_ranges(hostvars[item]['monitor_address_block'].split(',')) | last | ipwrap }] }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ groups.get(mon_group_name, []) }}"
|
2019-04-06 03:04:45 +08:00
|
|
|
when:
|
|
|
|
- "item not in _monitor_addresses | default([]) | selectattr('name', 'defined') | map(attribute='name') | list"
|
|
|
|
- hostvars[item]['monitor_address_block'] is defined
|
|
|
|
- hostvars[item]['monitor_address_block'] != 'subnet'
|
|
|
|
- ip_version == 'ipv6'
|
2018-10-03 22:09:33 +08:00
|
|
|
|
2020-03-23 23:14:29 +08:00
|
|
|
- name: set_fact _monitor_addresses to monitor_address
|
2018-10-03 22:09:33 +08:00
|
|
|
set_fact:
|
|
|
|
_monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['monitor_address'] | ipwrap}] }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ groups.get(mon_group_name, []) }}"
|
2018-10-03 22:09:33 +08:00
|
|
|
when:
|
|
|
|
- "item not in _monitor_addresses | default([]) | selectattr('name', 'defined') | map(attribute='name') | list"
|
|
|
|
- hostvars[item]['monitor_address'] is defined
|
2019-12-10 01:23:15 +08:00
|
|
|
- hostvars[item]['monitor_address'] != 'x.x.x.x'
|
2018-10-03 22:09:33 +08:00
|
|
|
|
2020-03-23 23:14:29 +08:00
|
|
|
- name: set_fact _monitor_addresses to monitor_interface - ipv4
|
2018-10-03 22:09:33 +08:00
|
|
|
set_fact:
|
2021-03-03 22:43:50 +08:00
|
|
|
_monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['ansible_facts'][(hostvars[item]['monitor_interface']|replace('-', '_'))][ip_version]['address'] | ipwrap }] }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ groups.get(mon_group_name, []) }}"
|
2018-10-03 22:09:33 +08:00
|
|
|
when:
|
2019-03-05 15:44:25 +08:00
|
|
|
- "item not in _monitor_addresses | default([]) | selectattr('name', 'defined') | map(attribute='name') | list"
|
2018-10-03 22:09:33 +08:00
|
|
|
- ip_version == 'ipv4'
|
|
|
|
- hostvars[item]['monitor_address_block'] | default('subnet') == 'subnet'
|
2019-12-10 01:23:15 +08:00
|
|
|
- hostvars[item]['monitor_address'] | default('x.x.x.x') == 'x.x.x.x'
|
2018-10-03 22:09:33 +08:00
|
|
|
- hostvars[item]['monitor_interface'] | default('interface') != 'interface'
|
|
|
|
|
2020-03-23 23:14:29 +08:00
|
|
|
- name: set_fact _monitor_addresses to monitor_interface - ipv6
|
2018-10-03 22:09:33 +08:00
|
|
|
set_fact:
|
2021-03-03 22:43:50 +08:00
|
|
|
_monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['ansible_facts'][(hostvars[item]['monitor_interface']|replace('-', '_'))][ip_version][0]['address'] | ipwrap }] }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ groups.get(mon_group_name, []) }}"
|
2018-10-03 22:09:33 +08:00
|
|
|
when:
|
2019-03-05 15:44:25 +08:00
|
|
|
- "item not in _monitor_addresses | default([]) | selectattr('name', 'defined') | map(attribute='name') | list"
|
2018-10-03 22:09:33 +08:00
|
|
|
- ip_version == 'ipv6'
|
|
|
|
- hostvars[item]['monitor_address_block'] | default('subnet') == 'subnet'
|
2019-12-10 01:23:15 +08:00
|
|
|
- hostvars[item]['monitor_address'] | default('x.x.x.x') == 'x.x.x.x'
|
2018-10-15 21:22:40 +08:00
|
|
|
- hostvars[item]['monitor_interface'] | default('interface') != 'interface'
|
|
|
|
|
|
|
|
- name: set_fact _current_monitor_address
|
|
|
|
set_fact:
|
2018-11-01 19:47:17 +08:00
|
|
|
_current_monitor_address: "{{ item.addr }}"
|
2018-10-15 21:22:40 +08:00
|
|
|
with_items: "{{ _monitor_addresses }}"
|
2021-10-28 22:17:24 +08:00
|
|
|
when:
|
|
|
|
- (inventory_hostname == item.name and not rolling_update | default(False) | bool)
|
|
|
|
or (rolling_update | default(False) | bool and item.name == groups.get(mon_group_name, [])[0])
|