From 63b3dadfbf6a4878b07f5a4713b5dca41712260b Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Thu, 12 May 2022 20:49:04 +0200 Subject: [PATCH] common: move to `ansible.utils.ipwrap` ipwrap has moved to ansible.utils see https://github.com/ansible-collections/ansible.netcommon/commit/db4920ebf6bae6476ff8829e2cf475f19f83a990 Signed-off-by: Guillaume Abrioux (cherry picked from commit c1649862a98f23f3f69518abe799c0f6842581d8) --- group_vars/all.yml.sample | 2 +- group_vars/rhcs.yml.sample | 2 +- infrastructure-playbooks/cephadm-adopt.yml | 2 +- infrastructure-playbooks/cephadm.yml | 2 +- roles/ceph-dashboard/tasks/configure_dashboard.yml | 2 +- roles/ceph-defaults/defaults/main.yml | 2 +- roles/ceph-facts/tasks/grafana.yml | 4 ++-- roles/ceph-facts/tasks/set_monitor_address.yml | 8 ++++---- roles/ceph-facts/tasks/set_radosgw_address.yml | 6 +++--- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/group_vars/all.yml.sample b/group_vars/all.yml.sample index 0a064a12f..782156838 100644 --- a/group_vars/all.yml.sample +++ b/group_vars/all.yml.sample @@ -746,7 +746,7 @@ dummy: # For example: # If the ceph public network is 2a00:8a60:1:c301::/64 and the iSCSI Gateway resides # at a dedicated gateway network (2a00:8a60:1:c300::/64) (With routing between those networks). -# It means "{{ hostvars[item]['ansible_facts']['all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | last | ipwrap }}" will be empty. +# It means "{{ hostvars[item]['ansible_facts']['all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | last | ansible.utils.ipwrap }}" will be empty. # As a consequence, this prevent from deploying dashboard with iSCSI node when it reside in a subnet different than `public_network`. # Using `igw_network` make it possible, set it with the subnet used by your iSCSI node. #igw_network: "{{ public_network }}" diff --git a/group_vars/rhcs.yml.sample b/group_vars/rhcs.yml.sample index 9de5774ad..a3e81ceff 100644 --- a/group_vars/rhcs.yml.sample +++ b/group_vars/rhcs.yml.sample @@ -746,7 +746,7 @@ alertmanager_container_image: registry.redhat.io/openshift4/ose-prometheus-alert # For example: # If the ceph public network is 2a00:8a60:1:c301::/64 and the iSCSI Gateway resides # at a dedicated gateway network (2a00:8a60:1:c300::/64) (With routing between those networks). -# It means "{{ hostvars[item]['ansible_facts']['all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | last | ipwrap }}" will be empty. +# It means "{{ hostvars[item]['ansible_facts']['all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | last | ansible.utils.ipwrap }}" will be empty. # As a consequence, this prevent from deploying dashboard with iSCSI node when it reside in a subnet different than `public_network`. # Using `igw_network` make it possible, set it with the subnet used by your iSCSI node. #igw_network: "{{ public_network }}" diff --git a/infrastructure-playbooks/cephadm-adopt.yml b/infrastructure-playbooks/cephadm-adopt.yml index 15396d08e..94686d8fc 100644 --- a/infrastructure-playbooks/cephadm-adopt.yml +++ b/infrastructure-playbooks/cephadm-adopt.yml @@ -367,7 +367,7 @@ when: ip_version == 'ipv4' - name: manage nodes with cephadm - ipv6 - command: "{{ ceph_cmd }} orch host add {{ ansible_facts['nodename'] }} {{ ansible_facts['all_ipv6_addresses'] | ips_in_ranges(cephadm_mgmt_network.split(',')) | last | ipwrap }} {{ group_names | intersect(adopt_label_group_names) | join(' ') }}" + command: "{{ ceph_cmd }} orch host add {{ ansible_facts['nodename'] }} {{ ansible_facts['all_ipv6_addresses'] | ips_in_ranges(cephadm_mgmt_network.split(',')) | last | ansible.utils.ipwrap }} {{ group_names | intersect(adopt_label_group_names) | join(' ') }}" changed_when: false delegate_to: '{{ groups[mon_group_name][0] }}' when: ip_version == 'ipv6' diff --git a/infrastructure-playbooks/cephadm.yml b/infrastructure-playbooks/cephadm.yml index f19672ae7..01a6ce2bd 100644 --- a/infrastructure-playbooks/cephadm.yml +++ b/infrastructure-playbooks/cephadm.yml @@ -249,7 +249,7 @@ when: ip_version == 'ipv4' - name: manage nodes with cephadm - ipv6 - command: "{{ cephadm_cmd }} shell -- ceph --cluster {{ cluster }} orch host add {{ ansible_facts['hostname'] }} {{ ansible_facts['all_ipv6_addresses'] | ips_in_ranges(public_network.split(',')) | last | ipwrap }} {{ group_names | join(' ') }} {{ '_admin' if mon_group_name | default('mons') in group_names else '' }}" + command: "{{ cephadm_cmd }} shell -- ceph --cluster {{ cluster }} orch host add {{ ansible_facts['hostname'] }} {{ ansible_facts['all_ipv6_addresses'] | ips_in_ranges(public_network.split(',')) | last | ansible.utils.ipwrap }} {{ group_names | join(' ') }} {{ '_admin' if mon_group_name | default('mons') in group_names else '' }}" changed_when: false delegate_to: '{{ groups[mon_group_name][0] }}' environment: diff --git a/roles/ceph-dashboard/tasks/configure_dashboard.yml b/roles/ceph-dashboard/tasks/configure_dashboard.yml index 5e03266ef..bc91f89b3 100644 --- a/roles/ceph-dashboard/tasks/configure_dashboard.yml +++ b/roles/ceph-dashboard/tasks/configure_dashboard.yml @@ -312,7 +312,7 @@ - name: add iscsi gateways - ipv6 command: "{{ ceph_cmd }} --cluster {{ cluster }} dashboard iscsi-gateway-add -i -" args: - stdin: "{{ 'https' if hostvars[item]['api_secure'] | default(false) | bool else 'http' }}://{{ hostvars[item]['api_user'] | default('admin') }}:{{ hostvars[item]['api_password'] | default('admin') }}@{{ hostvars[item]['ansible_facts']['all_ipv6_addresses'] | ips_in_ranges(igw_network.split(',')) | last | ipwrap }}:{{ hostvars[item]['api_port'] | default(5000) }}" + stdin: "{{ 'https' if hostvars[item]['api_secure'] | default(false) | bool else 'http' }}://{{ hostvars[item]['api_user'] | default('admin') }}:{{ hostvars[item]['api_password'] | default('admin') }}@{{ hostvars[item]['ansible_facts']['all_ipv6_addresses'] | ips_in_ranges(igw_network.split(',')) | last | ansible.utils.ipwrap }}:{{ hostvars[item]['api_port'] | default(5000) }}" stdin_add_newline: no changed_when: false delegate_to: "{{ groups[mon_group_name][0] }}" diff --git a/roles/ceph-defaults/defaults/main.yml b/roles/ceph-defaults/defaults/main.yml index 8fc86d838..1c4b783c9 100644 --- a/roles/ceph-defaults/defaults/main.yml +++ b/roles/ceph-defaults/defaults/main.yml @@ -738,7 +738,7 @@ alertmanager_dashboard_api_no_ssl_verify: "{{ true if dashboard_protocol == 'htt # For example: # If the ceph public network is 2a00:8a60:1:c301::/64 and the iSCSI Gateway resides # at a dedicated gateway network (2a00:8a60:1:c300::/64) (With routing between those networks). -# It means "{{ hostvars[item]['ansible_facts']['all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | last | ipwrap }}" will be empty. +# It means "{{ hostvars[item]['ansible_facts']['all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | last | ansible.utils.ipwrap }}" will be empty. # As a consequence, this prevent from deploying dashboard with iSCSI node when it reside in a subnet different than `public_network`. # Using `igw_network` make it possible, set it with the subnet used by your iSCSI node. igw_network: "{{ public_network }}" diff --git a/roles/ceph-facts/tasks/grafana.yml b/roles/ceph-facts/tasks/grafana.yml index 6228cd678..afd446da9 100644 --- a/roles/ceph-facts/tasks/grafana.yml +++ b/roles/ceph-facts/tasks/grafana.yml @@ -9,7 +9,7 @@ - name: set grafana_server_addr fact - ipv6 set_fact: - grafana_server_addr: "{{ hostvars[inventory_hostname]['ansible_facts']['all_ipv6_addresses'] | ips_in_ranges(grafana_network.split(',')) | last | ipwrap }}" + grafana_server_addr: "{{ hostvars[inventory_hostname]['ansible_facts']['all_ipv6_addresses'] | ips_in_ranges(grafana_network.split(',')) | last | ansible.utils.ipwrap }}" when: - groups.get(monitoring_group_name, []) | length > 0 - ip_version == 'ipv6' @@ -27,7 +27,7 @@ - name: set grafana_server_addrs fact - ipv6 set_fact: - grafana_server_addrs: "{{ (grafana_server_addrs | default([]) + [hostvars[item]['ansible_facts']['all_ipv6_addresses'] | ips_in_ranges(grafana_network.split(',')) | last | ipwrap]) | unique }}" + grafana_server_addrs: "{{ (grafana_server_addrs | default([]) + [hostvars[item]['ansible_facts']['all_ipv6_addresses'] | ips_in_ranges(grafana_network.split(',')) | last | ipansible.utils.ipwrapwrap]) | unique }}" with_items: "{{ groups.get(monitoring_group_name, []) }}" when: - groups.get(monitoring_group_name, []) | length > 0 diff --git a/roles/ceph-facts/tasks/set_monitor_address.yml b/roles/ceph-facts/tasks/set_monitor_address.yml index 6f512a85d..b1cb34667 100644 --- a/roles/ceph-facts/tasks/set_monitor_address.yml +++ b/roles/ceph-facts/tasks/set_monitor_address.yml @@ -11,7 +11,7 @@ - name: set_fact _monitor_addresses to monitor_address_block ipv6 set_fact: - _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 }] }}" + _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 | ansible.utils.ipwrap }] }}" with_items: "{{ groups.get(mon_group_name, []) }}" when: - "item not in _monitor_addresses | default([]) | selectattr('name', 'defined') | map(attribute='name') | list" @@ -21,7 +21,7 @@ - name: set_fact _monitor_addresses to monitor_address set_fact: - _monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['monitor_address'] | ipwrap}] }}" + _monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['monitor_address'] | ansible.utils.ipwrap}] }}" with_items: "{{ groups.get(mon_group_name, []) }}" when: - "item not in _monitor_addresses | default([]) | selectattr('name', 'defined') | map(attribute='name') | list" @@ -30,7 +30,7 @@ - name: set_fact _monitor_addresses to monitor_interface - ipv4 set_fact: - _monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['ansible_facts'][(hostvars[item]['monitor_interface']|replace('-', '_'))][ip_version]['address'] | ipwrap }] }}" + _monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['ansible_facts'][(hostvars[item]['monitor_interface']|replace('-', '_'))][ip_version]['address'] | ansible.utils.ipwrap }] }}" with_items: "{{ groups.get(mon_group_name, []) }}" when: - "item not in _monitor_addresses | default([]) | selectattr('name', 'defined') | map(attribute='name') | list" @@ -41,7 +41,7 @@ - name: set_fact _monitor_addresses to monitor_interface - ipv6 set_fact: - _monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['ansible_facts'][(hostvars[item]['monitor_interface']|replace('-', '_'))][ip_version][0]['address'] | ipwrap }] }}" + _monitor_addresses: "{{ _monitor_addresses | default([]) + [{ 'name': item, 'addr': hostvars[item]['ansible_facts'][(hostvars[item]['monitor_interface']|replace('-', '_'))][ip_version][0]['address'] | ansible.utils.ipwrap }] }}" with_items: "{{ groups.get(mon_group_name, []) }}" when: - "item not in _monitor_addresses | default([]) | selectattr('name', 'defined') | map(attribute='name') | list" diff --git a/roles/ceph-facts/tasks/set_radosgw_address.yml b/roles/ceph-facts/tasks/set_radosgw_address.yml index dfb1ea2cf..64d2b3b22 100644 --- a/roles/ceph-facts/tasks/set_radosgw_address.yml +++ b/roles/ceph-facts/tasks/set_radosgw_address.yml @@ -9,7 +9,7 @@ - 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 }}" + _radosgw_address: "{{ hostvars[inventory_hostname]['ansible_facts']['all_ipv6_addresses'] | ips_in_ranges(hostvars[inventory_hostname]['radosgw_address_block'].split(',')) | last | ansible.utils.ipwrap }}" when: - radosgw_address_block is defined - radosgw_address_block != 'subnet' @@ -17,7 +17,7 @@ - name: set_fact _radosgw_address to radosgw_address set_fact: - _radosgw_address: "{{ radosgw_address | ipwrap }}" + _radosgw_address: "{{ radosgw_address | ansible.utils.ipwrap }}" when: - radosgw_address is defined - radosgw_address != 'x.x.x.x' @@ -39,7 +39,7 @@ - name: set_fact _radosgw_address to radosgw_interface - ipv6 set_fact: - _radosgw_address: "{{ hostvars[inventory_hostname]['ansible_facts'][_interface][ip_version][0]['address'] | ipwrap }}" + _radosgw_address: "{{ hostvars[inventory_hostname]['ansible_facts'][_interface][ip_version][0]['address'] | ansible.utils.ipwrap }}" when: ip_version == 'ipv6' - name: set_fact rgw_instances without rgw multisite