--- # Copyright 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. - name: Deploy DCN environment hosts: localhost tasks: - name: Load reproducer-variables ansible.builtin.include_vars: file: "~/reproducer-variables.yml" - name: Load networking-environment-definition ansible.builtin.include_vars: file: "/etc/ci/env/networking-environment-definition.yml" name: cifmw_networking_env_definition - name: Create a network subnet list ansible.builtin.set_fact: _network_ranges: >- {{ cifmw_networking_env_definition.networks | dict2items | selectattr('key', 'search', '^ctlplane') | map(attribute='value.network_v4') | list }} - name: Get OpenShift access token register: _auth_results community.okd.openshift_auth: host: "{{ cifmw_openshift_api }}" username: "{{ cifmw_openshift_user }}" password: "{{ cifmw_openshift_password }}" validate_certs: false - name: Deploy EDPM loop: "{{ groups | dict2items | selectattr('key', 'search', 'compute') | list }}" loop_control: index_var: idx loop_var: itm vars: _az: "az{{ idx }}" _subnet: "subnet{{ idx + 1 }}" _subnet_network_range: "{{ _network_ranges[idx] }}" _group_name: "{{ itm.key }}" _group_hosts: "{{ groups[itm.key] }}" _edpm_hosts: "{{ cifmw_baremetal_hosts | dict2items | selectattr('key', 'in', groups[itm.key]) | items2dict }}" _ceph_bootstrap_node: "{{ (_edpm_hosts | dict2items | first).key if _edpm_hosts | length > 0 else '' }}" when: - _subnet_network_range != '' - _ceph_bootstrap_node != '' ansible.builtin.include_role: name: ci_dcn_site - name: The map for az0 contains all AZ backends ansible.builtin.set_fact: az_to_group_map: az0: computes az1: dcn1-compute-az1s az2: dcn2-compute-az2s - name: Scaledown the DCN site vars: _az_to_scaledown: "{{ cifmw_ci_dcn_site_scaledown_az }}" _subnet: "subnet{{ (az_to_group_map | dict2items | map(attribute='key') | list) | ansible.utils.index_of('eq', cifmw_ci_dcn_site_scaledown_az) + 1 }}" _group_name: "{{ az_to_group_map[cifmw_ci_dcn_site_scaledown_az] }}" _group_hosts: "{{ groups[az_to_group_map[cifmw_ci_dcn_site_scaledown_az]] }}" ansible.builtin.include_role: name: ci_dcn_site when: cifmw_ci_dcn_site_scaledown_az is defined and cifmw_ci_dcn_site_scaledown_az != "" - name: Remove a compute node from the deployment vars: _node_to_remove: "{{ cifmw_ci_dcn_site_scaledown_node }}" _az: "{{ cifmw_ci_dcn_site_scaledown_node_az | default('az1') }}" _group_name: "{{ az_to_group_map[_az] }}" _group_hosts: "{{ groups[_group_name] }}" _edpm_hosts: "{{ cifmw_baremetal_hosts | dict2items | selectattr('key', 'in', groups[_group_name]) | items2dict }}" _ceph_bootstrap_node: "{{ (_edpm_hosts | dict2items | first).key if _edpm_hosts | length > 0 else '' }}" when: - cifmw_ci_dcn_site_scaledown_node is defined and cifmw_ci_dcn_site_scaledown_node != "" ansible.builtin.include_role: name: ci_dcn_site tasks_from: remove_node.yml - name: Add a compute node to a site when: - cifmw_ci_dcn_site_scaleout_node is defined and cifmw_ci_dcn_site_scaleout_node != "" block: # We need to update ci-framework related variable and inventory files to include the new host - name: Update ci-framework variables and inventory files vars: _node_to_add: "{{ cifmw_ci_dcn_site_scaleout_node }}" _az: "{{ cifmw_ci_dcn_site_scaleout_node_az | default('az1') }}" _subnet: "{{ cifmw_ci_dcn_site_scaleout_node_subnet | default('subnet2') }}" _group_name: "{{ az_to_group_map[_az] }}" ansible.builtin.include_role: name: ci_dcn_site tasks_from: update_conf_new_node.yml - name: Add a compute node to dataplane vars: _node_to_add: "{{ cifmw_ci_dcn_site_scaleout_node }}" _az: "{{ cifmw_ci_dcn_site_scaleout_node_az | default('az1') }}" _subnet: "{{ cifmw_ci_dcn_site_scaleout_node_subnet | default('subnet2') }}" _subnet_network_range: "{{ _network_ranges[_az[-1] | int] }}" _group_name: "{{ az_to_group_map[_az] }}" _group_hosts: "{{ groups[_group_name] }}" _edpm_hosts: "{{ updated_cifmw_baremetal_hosts | dict2items | selectattr('key', 'in', groups[_group_name]) | items2dict }}" _ceph_bootstrap_node: "{{ (_edpm_hosts | dict2items | first).key if _edpm_hosts | length > 0 else '' }}" ansible.builtin.include_role: name: ci_dcn_site tasks_from: add_node.yml - name: Find all created CRs ansible.builtin.find: paths: >- {{ (ansible_user_dir, 'src', 'github.com', 'openstack-k8s-operators', 'architecture', 'examples', 'dt', cifmw_architecture_scenario) | path_join }} file_type: file patterns: - "control*.yaml" - "dataplane*.yaml" register: dcn_crs - name: Copy found CR files to the manifests folder ansible.builtin.copy: src: "{{ item.path }}" dest: "{{ cifmw_manifests_dir }}/openstack/cr" mode: "0644" loop: "{{ dcn_crs.files }}" when: dcn_crs.matched > 0