--- # 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: Set EDPM related vars when: - cifmw_install_yamls_environment is defined - cifmw_install_yamls_defaults is defined tags: - always ansible.builtin.set_fact: cifmw_edpm_deploy_env: >- {{ cifmw_install_yamls_environment | combine({'PATH': cifmw_path}) | combine({'DATAPLANE_REGISTRY_URL': cifmw_edpm_deploy_registry_url }) | combine({'DATAPLANE_CONTAINER_TAG': cifmw_repo_setup_full_hash | default(cifmw_install_yamls_defaults['DATAPLANE_CONTAINER_TAG']) }) | combine(cifmw_edpm_deploy_extra_vars | default({})) | combine(_install_yamls_repos | default({})) }} cacheable: true - name: Pass through extra nova-compute config when: cifmw_edpm_deploy_nova_compute_extra_config is defined tags: - always vars: _cifmw_edpm_deploy_nova_extra_config_file: "{{ cifmw_edpm_deploy_basedir }}/nova-extra-config.conf" block: - name: Create the config file ansible.builtin.copy: mode: "0644" content: "{{ cifmw_edpm_deploy_nova_compute_extra_config }}" dest: "{{ _cifmw_edpm_deploy_nova_extra_config_file }}" - name: Define DATAPLANE_EXTRA_NOVA_CONFIG_FILE ansible.builtin.set_fact: cifmw_edpm_deploy_env: >- {{ cifmw_edpm_deploy_env | default({}) | combine({'DATAPLANE_EXTRA_NOVA_CONFIG_FILE': _cifmw_edpm_deploy_nova_extra_config_file }) }} cacheable: true - name: Prepare OpenStack Dataplane NodeSet CR when: cifmw_edpm_deploy_prepare_run | bool vars: make_edpm_deploy_prep_env: "{{ cifmw_edpm_deploy_env }}" make_edpm_deploy_prep_dryrun: "{{ cifmw_edpm_deploy_dryrun | bool }}" ansible.builtin.include_role: name: 'install_yamls_makes' tasks_from: 'make_edpm_deploy_prep' - name: Kustomize and deploy OpenStackDataPlaneNodeSet when: - not cifmw_edpm_deploy_dryrun | bool vars: cifmw_edpm_deploy_openstack_crs_path: >- {{ [ cifmw_edpm_deploy_manifests_dir, cifmw_install_yamls_defaults['NAMESPACE'], 'dataplane', 'cr' ] | ansible.builtin.path_join }} environment: PATH: "{{ cifmw_path }}" KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" block: - name: Perform kustomizations to the OpenStackDataPlaneNodeSet CR when: not cifmw_edpm_deploy_dryrun cifmw.general.ci_kustomize: target_path: "{{ cifmw_edpm_deploy_openstack_crs_path }}" sort_ascending: false kustomizations_paths: >- {{ [ ( [ cifmw_edpm_deploy_manifests_dir, 'kustomizations', 'dataplane' ] | ansible.builtin.path_join ) ] }} register: cifmw_edpm_deploy_crs_kustomize_result - name: Log the CR that is about to be applied when: not cifmw_edpm_deploy_dryrun ansible.builtin.debug: var: cifmw_edpm_deploy_crs_kustomize_result - name: Apply dataplane resources but ignore DataPlaneDeployment kubernetes.core.k8s: kubeconfig: "{{ cifmw_openshift_kubeconfig }}" api_key: "{{ cifmw_openshift_token | default(omit) }}" context: "{{ cifmw_openshift_context | default(omit) }}" state: present definition: "{{ lookup('file', cifmw_edpm_deploy_crs_kustomize_result.output_path) | from_yaml_all | rejectattr('kind', 'search', cifmw_edpm_deploy_step2_kind) }}" - name: Wait for OpenStackDataPlaneNodeSet become SetupReady when: not cifmw_edpm_deploy_dryrun vars: cr_name: >- {{ ( cifmw_edpm_deploy_crs_kustomize_result.result | selectattr('kind', 'defined') | selectattr('metadata.name', 'defined') | selectattr('kind', 'equalto', 'OpenStackDataPlaneNodeSet') | first ).metadata.name }} environment: KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" PATH: "{{ cifmw_path }}" ansible.builtin.command: cmd: >- oc wait OpenStackDataPlaneNodeSet {{ cr_name }} --namespace={{ cifmw_install_yamls_defaults['NAMESPACE'] }} --for=condition=SetupReady --timeout={{ cifmw_edpm_deploy_timeout }}m - name: Apply DataPlaneDeployment resource kubernetes.core.k8s: kubeconfig: "{{ cifmw_openshift_kubeconfig }}" api_key: "{{ cifmw_openshift_token | default(omit) }}" context: "{{ cifmw_openshift_context | default(omit) }}" state: present definition: "{{ lookup('file', cifmw_edpm_deploy_crs_kustomize_result.output_path) | from_yaml_all | selectattr('kind', 'search', cifmw_edpm_deploy_step2_kind) }}" - name: Wait for OpenStackDataPlaneDeployment become Ready when: not cifmw_edpm_deploy_dryrun vars: cr_name: >- {{ ( cifmw_edpm_deploy_crs_kustomize_result.result | selectattr('kind', 'defined') | selectattr('metadata.name', 'defined') | selectattr('kind', 'equalto', 'OpenStackDataPlaneDeployment') | first ).metadata.name }} environment: KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" PATH: "{{ cifmw_path }}" ansible.builtin.command: cmd: >- oc wait OpenStackDataPlaneDeployment {{ cr_name }} --namespace={{ cifmw_install_yamls_defaults['NAMESPACE'] }} --for=condition=Ready --timeout={{ cifmw_edpm_deploy_timeout }}m - name: Run nova-manage discover_hosts to ensure compute nodes are mapped when: - not cifmw_edpm_deploy_dryrun | bool - not cifmw_edpm_deploy_skip_nova_discover_hosts | default(false) | bool environment: PATH: "{{ cifmw_path }}" KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" cifmw.general.ci_script: output_dir: "{{ cifmw_basedir }}/artifacts" executable: "/bin/bash" script: | set -xe oc rsh --namespace={{ cifmw_install_yamls_defaults['NAMESPACE'] }} nova-cell0-conductor-0 nova-manage cell_v2 discover_hosts --verbose - name: Validate EDPM when: cifmw_edpm_deploy_run_validation | bool vars: make_edpm_deploy_instance_env: "{{ cifmw_edpm_deploy_env }}" ansible.builtin.include_role: name: 'install_yamls_makes' tasks_from: 'make_edpm_deploy_instance'