--- # Copyright 2022 Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # Assumes the following module is in ANSIBLE_LIBRARY=/usr/share/ansible/library/ # https://github.com/ceph/ceph-ansible/blob/master/library/ceph_pool.py - fail: msg: stack_name is a required input when: - stack_name is undefined - fail: msg: ceph_service_mapping is a required input when: - tripleo_cephadm_ha_services_path is undefined - name: Load Virtual IP Ceph networks data config from file set_fact: ceph_vip_map: "{{ lookup('file', tripleo_cephadm_ha_services_path) | from_yaml }}" when: - ceph_vip_map is undefined - name: Store reserved vip info set_fact: render_path: '{{ working_dir }}/ceph_vips.yaml' - name: Network/Subnet based Ceph VIPs build block: - name: Sanity check on user input fail: msg: ERROR, subnet or network missing! when: - item.get('network', '') | length == 0 - item.get('subnet', '') | length == 0 loop: "{{ ceph_vip_map.get('ceph_services', {}) }}" - name: Build Ceph VIPs (subnet) tripleo_service_vip: render_path: "{{ render_path }}" stack_name: "{{ stack_name }}" service_name: "{{ item.service }}" network: "{{ item.network }}" fixed_ips: - {"subnet": "{{ item.get('subnet', item.network + '_subnet') }}"} loop: "{{ ceph_vip_map.get('ceph_services', {}) }}" register: services_subnet when: not ceph_vip_map.get('fixed') - name: Fixed IPs based Ceph VIPs build block: - name: Sanity check on user input fail: msg: ERROR, missing fixed ip_address! when: - item.get('ip_address','') | length == 0 loop: "{{ ceph_vip_map.get('ceph_services', {}) }}" - name: Build Ceph VIPs (fixed_ips) tripleo_service_vip: render_path: "{{ render_path }}" stack_name: "{{ stack_name }}" service_name: "{{ item.service }}" network: "{{ item.network }}" fixed_ips: - {"ip_address": "{{ item.get('ip_address', None) }}"} loop: "{{ ceph_vip_map.get('ceph_services', {}) }}" register: services_fixed when: ceph_vip_map.get('fixed') - name: set ceph services vip data set_fact: tripleo_cephadm_ceph_vips: | {% if ceph_vip_map.get('fixed') %} {% set _len = (services_fixed.results | length | int) -1 %} {{ services_fixed.results[_len].data }} {% else %} {% set _len = (services_subnet.results | length | int) -1 %} {{ services_subnet.results[_len].data }} {% endif %}