Skip to content

Commit 242c946

Browse files
eshulman2evallesp
authored andcommitted
Clean deployment resources as well as operators
Allowed cleaning up deployment resources as well as operators.
1 parent 1dcf732 commit 242c946

2 files changed

Lines changed: 53 additions & 5 deletions

File tree

clean_openstack_deployment.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- name: Clean OpenStack deployment
2+
hosts: "{{ target_host | default('localhost') }}"
3+
gather_facts: false
4+
tasks:
5+
- name: Clean up OpenStack operators
6+
vars:
7+
cifmw_kustomize_deploy_keep_generated_crs: false
8+
ansible.builtin.include_role:
9+
name: kustomize_deploy
10+
tasks_from: cleanup

roles/kustomize_deploy/tasks/cleanup.yml

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,52 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17+
- name: Load architecture automation file
18+
register: _automation
19+
ansible.builtin.slurp:
20+
path: "{{ cifmw_architecture_automation_file }}"
21+
22+
- name: Prepare automation data
23+
vars:
24+
_parsed: "{{ _automation.content | b64decode | from_yaml }}"
25+
ansible.builtin.set_fact:
26+
cifmw_deploy_architecture_steps: >-
27+
{{ _parsed['vas'][cifmw_architecture_scenario] }}
28+
29+
- name: Generate list of CRs to delete
30+
vars:
31+
_stages_crs: >-
32+
{{
33+
cifmw_deploy_architecture_steps['stages'] |
34+
reverse |
35+
selectattr('build_output', 'defined') |
36+
map(attribute='build_output') |
37+
list
38+
}}
39+
_stages_crs_path: >-
40+
{{
41+
[cifmw_kustomize_deploy_kustomizations_dest_dir]
42+
| product(_stages_crs)
43+
| map('join', '/')
44+
| unique
45+
}}
46+
_operators_crs:
47+
- "{{ cifmw_kustomize_deploy_nmstate_dest_file }}"
48+
- "{{ cifmw_kustomize_deploy_metallb_dest_file }}"
49+
- "{{ cifmw_kustomize_deploy_kustomizations_dest_dir }}/openstack.yaml"
50+
- "{{ cifmw_kustomize_deploy_olm_dest_file }}"
51+
register: _cifmw_kustomize_files
52+
ansible.builtin.set_fact:
53+
cifmw_kustomize_deploy_crs_to_delete: >-
54+
{{
55+
_stages_crs_path +
56+
_operators_crs
57+
}}
58+
1759
- name: Ensure that kustomization files are present
1860
ansible.builtin.stat:
1961
path: "{{ item }}"
20-
loop:
21-
- "{{ cifmw_kustomize_deploy_cp_dest_file }}"
22-
- "{{ cifmw_kustomize_deploy_nmstate_dest_file }}"
23-
- "{{ cifmw_kustomize_deploy_metallb_dest_file }}"
24-
- "{{ cifmw_kustomize_deploy_olm_dest_file }}"
62+
loop: "{{ cifmw_kustomize_deploy_crs_to_delete }}"
2563
register: _cifmw_kustomize_files
2664

2765
- name: Cleaning operators resources

0 commit comments

Comments
 (0)