ceph-ansible/roles/ceph-facts/tasks/set_radosgw_address.yml

85 lines
3.9 KiB
YAML

---
- name: set_fact _radosgw_address to radosgw_address_block ipv4
set_fact:
_radosgw_address: "{{ hostvars[inventory_hostname]['ansible_facts']['all_ipv4_addresses'] | ips_in_ranges(hostvars[inventory_hostname]['radosgw_address_block'].split(',')) | first }}"
when:
- radosgw_address_block is defined
- radosgw_address_block != 'subnet'
- ip_version == 'ipv4'
- name: set_fact _radosgw_address to radosgw_address_block ipv6
set_fact:
_radosgw_address: "{{ hostvars[inventory_hostname]['ansible_facts']['all_ipv6_addresses'] | ips_in_ranges(hostvars[inventory_hostname]['radosgw_address_block'].split(',')) | last | ipwrap }}"
when:
- radosgw_address_block is defined
- radosgw_address_block != 'subnet'
- ip_version == 'ipv6'
- name: set_fact _radosgw_address to radosgw_address
set_fact:
_radosgw_address: "{{ radosgw_address | ipwrap }}"
when:
- radosgw_address is defined
- radosgw_address != 'x.x.x.x'
- name: tasks for radosgw interface
when:
- radosgw_address_block == 'subnet'
- radosgw_address == 'x.x.x.x'
- radosgw_interface != 'interface'
block:
- name: set_fact _interface
set_fact:
_interface: "{{ (radosgw_interface | replace('-', '_')) }}"
- name: set_fact _radosgw_address to radosgw_interface - ipv4
set_fact:
_radosgw_address: "{{ hostvars[inventory_hostname]['ansible_facts'][_interface][ip_version]['address'] }}"
when: ip_version == 'ipv4'
- name: set_fact _radosgw_address to radosgw_interface - ipv6
set_fact:
_radosgw_address: "{{ hostvars[inventory_hostname]['ansible_facts'][_interface][ip_version][0]['address'] | ipwrap }}"
when: ip_version == 'ipv6'
- name: set_fact rgw_instances without rgw multisite
set_fact:
rgw_instances: "{{ rgw_instances|default([]) | union([{'instance_name': 'rgw' + item|string, 'radosgw_address': _radosgw_address, 'radosgw_frontend_port': radosgw_frontend_port|int + item|int }]) }}"
with_sequence: start=0 end={{ radosgw_num_instances|int - 1 }}
when:
- inventory_hostname in groups.get(rgw_group_name, [])
- not rgw_multisite | bool
- name: set_fact is_rgw_instances_defined
set_fact:
is_rgw_instances_defined: "{{ rgw_instances is defined }}"
when:
- inventory_hostname in groups.get(rgw_group_name, [])
- rgw_multisite | bool
- name: set_fact rgw_instances with rgw multisite
set_fact:
rgw_instances: "{{ rgw_instances|default([]) | union([{ 'instance_name': 'rgw' + item | string, 'radosgw_address': _radosgw_address, 'radosgw_frontend_port': radosgw_frontend_port | int + item|int, 'rgw_realm': rgw_realm | string, 'rgw_zonegroup': rgw_zonegroup | string, 'rgw_zone': rgw_zone | string, 'system_access_key': system_access_key, 'system_secret_key': system_secret_key, 'rgw_zone_user': rgw_zone_user, 'rgw_zone_user_display_name': rgw_zone_user_display_name, 'endpoint': (rgw_pull_proto + '://' + rgw_pullhost + ':' + rgw_pull_port | string) if not rgw_zonemaster | bool and rgw_zonesecondary | bool else omit }]) }}"
with_sequence: start=0 end={{ radosgw_num_instances|int - 1 }}
when:
- inventory_hostname in groups.get(rgw_group_name, [])
- rgw_multisite | bool
- not is_rgw_instances_defined | default(False) | bool
- name: set_fact rgw_instances_host
set_fact:
rgw_instances_host: '{{ rgw_instances_host | default([]) | union([item | combine({"host": inventory_hostname})]) }}'
with_items: '{{ rgw_instances }}'
when:
- inventory_hostname in groups.get(rgw_group_name, [])
- rgw_multisite | bool
- name: set_fact rgw_instances_all
set_fact:
rgw_instances_all: '{{ rgw_instances_all | default([]) | union(hostvars[item]["rgw_instances_host"]) }}'
with_items: "{{ groups.get(rgw_group_name, []) }}"
when:
- inventory_hostname in groups.get(rgw_group_name, [])
- hostvars[item]["rgw_instances_host"] is defined
- hostvars[item]["rgw_multisite"] | default(False) | bool