--- # 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: Load architecture automation file register: _automation ansible.builtin.slurp: path: "{{ cifmw_architecture_automation_file }}" - name: Prepare automation data vars: _parsed: "{{ _automation.content | b64decode | from_yaml }}" ansible.builtin.set_fact: cifmw_deploy_architecture_steps: >- {{ _parsed['vas'][cifmw_architecture_scenario] }} - name: Generate list of CRs to delete vars: _stages_crs: >- {{ cifmw_deploy_architecture_steps['stages'] | reverse | selectattr('build_output', 'defined') | map(attribute='build_output') | map('basename') | list }} _stages_crs_path: >- {{ [cifmw_kustomize_deploy_kustomizations_dest_dir] | product(_stages_crs) | map('join', '/') | unique }} _operators_crs: - "{{ cifmw_kustomize_deploy_nmstate_dest_file }}" - "{{ cifmw_kustomize_deploy_metallb_dest_file }}" - "{{ cifmw_kustomize_deploy_kustomizations_dest_dir }}/openstack.yaml" - "{{ cifmw_kustomize_deploy_olm_dest_file }}" _external_dns_crs: - "{{ cifmw_manifests_dir }}/cifmw_external_dns/ceph-local-dns.yml" - "{{ cifmw_manifests_dir }}/cifmw_external_dns/ceph-local-cert.yml" register: _cifmw_kustomize_files ansible.builtin.set_fact: cifmw_kustomize_deploy_crs_to_delete: >- {{ _external_dns_crs + _stages_crs_path + _operators_crs }} - name: Ensure that kustomization files are present ansible.builtin.stat: path: "{{ item }}" loop: "{{ cifmw_kustomize_deploy_crs_to_delete }}" register: _cifmw_kustomize_files - name: Cleaning operators resources kubernetes.core.k8s: kubeconfig: "{{ cifmw_openshift_kubeconfig }}" api_key: "{{ cifmw_openshift_token | default(omit) }}" context: "{{ cifmw_openshift_context | default(omit) }}" state: absent src: "{{ item.stat.path }}" wait: true wait_timeout: 600 loop: "{{ _cifmw_kustomize_files.results }}" register: _cleanup_results until: "_cleanup_results is success" retries: 3 delay: 120 when: - item.stat.exists - not cifmw_kustomize_deploy_generate_crs_only - name: Cleanup generated CRs if requested ansible.builtin.file: path: "{{ item.stat.path }}" state: absent loop: "{{ _cifmw_kustomize_files.results }}" when: - item.stat.exists - cifmw_kustomize_deploy_keep_generated_crs | default(true, true)