-
Notifications
You must be signed in to change notification settings - Fork 2
/
down-network.yaml
123 lines (101 loc) · 3.83 KB
/
down-network.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Required Python packages:
#
# ansible
# openstackclient
# openstacksdk
- import_playbook: common.yaml
- import_playbook: net2-common.yaml
when: net2 | default(false) | bool
- import_playbook: eg-common.yaml
when: extraGateway | default(false) | bool
- hosts: all
gather_facts: no
tasks:
- name: 'Remove all routes from router'
command:
cmd: "openstack router set --no-route {{ os_router }}"
- name: 'Remove all routes from Net2 router'
command:
cmd: "openstack router set --no-route {{ os_net2_router }}"
when: net2 | default(false) | bool
- name: 'Remove all routes from EG router on Pri net'
command:
cmd: "openstack router set --no-route {{ os_eg_router }}"
when: extraGateway | default(false) | bool
- name: 'List ports attached to routers'
command:
cmd: "openstack port list --device-owner=network:router_interface --tags {{ cluster_id_tag }} -f value -c id"
register: router_ports
- name: 'Remove the ports from router'
command:
cmd: "openstack router remove port {{ os_router }} {{ item.1}}"
with_indexed_items: "{{ router_ports.stdout_lines }}"
- name: 'Remove the ports from Net2 router'
command:
cmd: "openstack router remove port {{ os_net2_router }} {{ item.1}}"
with_indexed_items: "{{ router_ports.stdout_lines }}"
when: net2 | default(false) | bool
- name: 'Remove the ports from EG router on Pri net'
command:
cmd: "openstack router remove port {{ os_eg_router }} {{ item.1}}"
with_indexed_items: "{{ router_ports.stdout_lines }}"
when: extraGateway | default(false) | bool
- name: 'List ha ports attached to router'
command:
cmd: "openstack port list --device-owner=network:ha_router_replicated_interface --tags {{ cluster_id_tag }} -f value -c id"
register: ha_router_ports
- name: 'Remove the ha ports from router'
command:
cmd: "openstack router remove port {{ os_router }} {{ item.1}}"
with_indexed_items: "{{ ha_router_ports.stdout_lines }}"
- name: 'Remove the ha ports from Net2 router'
command:
cmd: "openstack router remove port {{ os_net2_router }} {{ item.1}}"
with_indexed_items: "{{ ha_router_ports.stdout_lines }}"
when: net2 | default(false) | bool
- name: 'Remove the ha ports from EG router on Pri net'
command:
cmd: "openstack router remove port {{ os_eg_router }} {{ item.1}}"
with_indexed_items: "{{ ha_router_ports.stdout_lines }}"
when: extraGateway | default(false) | bool
- name: 'List ports'
command:
cmd: "openstack port list --tags {{ cluster_id_tag }} -f value -c id"
register: ports
- name: 'Remove the cluster ports'
command:
cmd: "openstack port delete {{ ports.stdout_lines | join(' ') }}"
when: ports.stdout != ""
- name: 'Remove the cluster router'
os_router:
name: "{{ os_router }}"
state: absent
- name: 'Remove the Net2 router'
os_router:
name: "{{ os_net2_router }}"
state: absent
when: net2 | default(false) | bool
- name: 'Remove the EG router for Pri net'
os_router:
name: "{{ os_eg_router }}"
state: absent
when: extraGateway | default(false) | bool
- name: 'List cluster networks'
command:
cmd: "openstack network list --tags {{ cluster_id_tag }} -f value -c ID"
register: networks
- name: 'Remove the cluster networks'
command:
cmd: "openstack network delete {{ networks.stdout_lines | join(' ') }}"
when: networks.stdout != ""
- name: 'List the cluster subnet pool'
command:
cmd: "openstack subnet pool list --name {{ subnet_pool }}"
when: os_networking_type == "Kuryr"
register: pods_subnet_pool
- name: 'Remove the cluster subnet pool'
command:
cmd: "openstack subnet pool delete {{ subnet_pool }}"
when:
- os_networking_type == "Kuryr"
- pods_subnet_pool.stdout != ""