-
Notifications
You must be signed in to change notification settings - Fork 16
/
ocp_cleanup.yml
32 lines (29 loc) · 1.2 KB
/
ocp_cleanup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
- name: Determine undercloud and allocate inventory
hosts: localhost
gather_facts: false
vars_files:
- vars/shift_stack_vars.yaml
tasks:
- name: list openstack projects for installed clusters
shell: |
ansible all -i '{{ undercloud_host }},' -m shell -a 'source /home/stack/overcloudrc && openstack project list -c Name -f value | grep {{ cluster_name_prefix }}' -e "ansible_user={{ undercloud_user }} ansible_ssh_pass={{ undercloud_password }}" | grep {{ cluster_name_prefix }}
register: osp_project_list
- name: Add undercloud host to inventory for each cluster, that are to be deleted
add_host:
name: "undercloud-{{ item }}"
group: undercloud_host
ansible_host: "{{ undercloud_host }}"
ansible_connection: "ssh"
ansible_user: "{{ undercloud_user }}"
ansible_ssh_pass: "{{ undercloud_password }}"
osp_project_name: "{{ item }}"
loop: "{{ osp_project_list.stdout_lines }}"
- hosts: undercloud_host
gather_facts: true
vars:
ocp_cluster_name: "{{ osp_project_name }}"
osp_user_name: "{{ osp_project_name }}"
tasks:
- name: destroy ocp cluster(s)
include_tasks: tasks/delete_ocp_cluster.yml