forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdown-control-plane.yaml
58 lines (49 loc) · 1.86 KB
/
down-control-plane.yaml
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Required Python packages:
#
# ansible
# openstackclient
# openstacksdk
- import_playbook: common.yaml
- hosts: all
gather_facts: no
tasks:
- name: 'Remove the Control Plane servers'
os_server:
name: "{{ item.1 }}-{{ item.0 }}"
state: absent
with_indexed_items: "{{ [os_cp_server_name] * os_cp_nodes_number }}"
- name: 'List the Server groups'
command:
# os-compute-api-version 2.15 or higher is required for the 'soft-anti-affinity' policy
cmd: "openstack --os-compute-api-version=2.15 server group list -f json -c ID -c Name"
register: server_group_list
- name: 'Parse the Server group ID from existing'
set_fact:
server_group_id: "{{ (server_group_list.stdout | from_json | json_query(list_query) | first).ID }}"
vars:
list_query: "[?Name=='{{ os_cp_server_group_name }}']"
when:
- "os_cp_server_group_name|string in server_group_list.stdout"
- name: 'Remove the Control Plane server group'
command:
# os-compute-api-version 2.15 or higher is required for the 'soft-anti-affinity' policy
cmd: "openstack --os-compute-api-version=2.15 server group delete {{ server_group_id }}"
when:
- server_group_id is defined
- name: 'List the Compute trunks'
command:
cmd: "openstack network trunk list -c Name -f value"
when: os_networking_type == "Kuryr"
register: trunks
- name: 'Remove the Control Plane trunks'
command:
cmd: "openstack network trunk delete {{ item.1 }}-{{ item.0 }}"
when:
- os_networking_type == "Kuryr"
- (item.1|string + '-' + item.0|string) in trunks.stdout_lines|list
with_indexed_items: "{{ [os_cp_trunk_name] * os_cp_nodes_number }}"
- name: 'Remove the Control Plane ports'
os_port:
name: "{{ item.1 }}-{{ item.0 }}"
state: absent
with_indexed_items: "{{ [os_port_master] * os_cp_nodes_number }}"