|
| 1 | +--- |
| 2 | +- name: Include required vars |
| 3 | + ansible.builtin.include_vars: |
| 4 | + file: "{{ item }}" |
| 5 | + loop: |
| 6 | + - roles/kustomize_deploy/defaults/main.yml |
| 7 | + - roles/deploy_bmh/defaults/main.yml |
| 8 | + |
| 9 | +- name: Load architecture automation file |
| 10 | + register: _automation |
| 11 | + ansible.builtin.slurp: |
| 12 | + path: "{{ cifmw_architecture_automation_file }}" |
| 13 | + |
| 14 | +- name: Prepare automation data |
| 15 | + vars: |
| 16 | + _parsed: "{{ _automation.content | b64decode | from_yaml }}" |
| 17 | + ansible.builtin.set_fact: |
| 18 | + cifmw_deploy_architecture_steps: >- |
| 19 | + {{ _parsed['vas'][cifmw_architecture_scenario] }} |
| 20 | +
|
| 21 | +- name: Clean up testing resources |
| 22 | + ansible.builtin.include_role: |
| 23 | + name: test_operator |
| 24 | + tasks_from: cleanup |
| 25 | + |
| 26 | +- name: Set baremetal hosts facts |
| 27 | + vars: |
| 28 | + _cifmw_deploy_bmh_bm_hosts: >- |
| 29 | + {{ |
| 30 | + cifmw_baremetal_hosts | default({}) | dict2items | |
| 31 | + rejectattr('key', 'in', ['crc', 'controller', 'ocp']) | |
| 32 | + items2dict |
| 33 | + }} |
| 34 | + ansible.builtin.set_fact: |
| 35 | + cifmw_deploy_bmh_bm_hosts_list: "{{ _cifmw_deploy_bmh_bm_hosts.keys() | list | default([]) }}" |
| 36 | + |
| 37 | +- name: Get bmh crs |
| 38 | + ansible.builtin.find: |
| 39 | + path: "{{ cifmw_deploy_bmh_dest_dir }}" |
| 40 | + patterns: "*.yml" |
| 41 | + excludes: "bmh-secret*" |
| 42 | + register: bmh_crs |
| 43 | + |
| 44 | +- name: Get bmh secrets crs |
| 45 | + ansible.builtin.find: |
| 46 | + path: "{{ cifmw_deploy_bmh_dest_dir }}" |
| 47 | + patterns: "bmh-secret*" |
| 48 | + register: bmh_secrets_crs |
| 49 | + |
| 50 | +- name: Detach bmh to skip deprovisioning |
| 51 | + ansible.builtin.import_tasks: detach_bmh.yaml |
| 52 | + when: cifmw_cleanup_openstack_detach_bmh |
| 53 | + |
| 54 | +- name: Delete deployment CRs |
| 55 | + vars: |
| 56 | + _stages_crs: >- |
| 57 | + {{ |
| 58 | + cifmw_deploy_architecture_steps['stages'] | |
| 59 | + reverse | |
| 60 | + selectattr('build_output', 'defined') | |
| 61 | + map(attribute='build_output') | |
| 62 | + map('basename') | |
| 63 | + list |
| 64 | + }} |
| 65 | + _stages_crs_path: >- |
| 66 | + {{ |
| 67 | + [cifmw_kustomize_deploy_kustomizations_dest_dir] |
| 68 | + | product(_stages_crs) |
| 69 | + | map('join', '/') |
| 70 | + | unique |
| 71 | + }} |
| 72 | + _external_dns_crs: |
| 73 | + - /home/zuul/ci-framework-data/artifacts/manifests/cifmw_external_dns/ceph-local-dns.yml |
| 74 | + - /home/zuul/ci-framework-data/artifacts/manifests/cifmw_external_dns/ceph-local-cert.yml |
| 75 | + _operators_crs: |
| 76 | + - "{{ cifmw_kustomize_deploy_nmstate_dest_file }}" |
| 77 | + - "{{ cifmw_kustomize_deploy_metallb_dest_file }}" |
| 78 | + - "{{ cifmw_kustomize_deploy_kustomizations_dest_dir }}/openstack.yaml" |
| 79 | + - "{{ cifmw_kustomize_deploy_olm_dest_file }}" |
| 80 | + _bmh_crs: >- |
| 81 | + {{ |
| 82 | + bmh_crs.files | |
| 83 | + map(attribute='path') | |
| 84 | + list |
| 85 | + }} |
| 86 | + _bmh_secrets_crs: >- |
| 87 | + {{ |
| 88 | + bmh_secrets_crs.files | |
| 89 | + map(attribute='path') | |
| 90 | + list |
| 91 | + }} |
| 92 | + _crs_to_delete: >- |
| 93 | + {{ |
| 94 | + _external_dns_crs + |
| 95 | + _stages_crs_path + |
| 96 | + _bmh_crs + |
| 97 | + _bmh_secrets_crs + |
| 98 | + _operators_crs |
| 99 | + }} |
| 100 | + ansible.builtin.import_tasks: cleanup_crs.yaml |
| 101 | + |
| 102 | +- name: Remove logs and tests directories |
| 103 | + ansible.builtin.file: |
| 104 | + path: "{{ item }}" |
| 105 | + state: absent |
| 106 | + loop: |
| 107 | + - "/home/zuul/ci-framework-data/logs" |
| 108 | + - "/home/zuul/ci-framework-data/tests" |
| 109 | + become: true |
0 commit comments