-
Notifications
You must be signed in to change notification settings - Fork 1
/
add-portworx.yaml
337 lines (307 loc) · 12 KB
/
add-portworx.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
- hosts: localhost
vars:
deploy_portworx_storage: false
tasks:
# This inserts the parameters and resources necessary for portworx
# It searchs for comments in the base files which reference
# add-portworx.yaml
#
# We make a copy of each yaml file that is modified -
# ... the *_pwx.yaml files are in gitignore.
#
# Create copies of files to be changed
- name: create portworx network file
copy:
src: ./network.yaml
dest: ./network_pwx.yaml
when: deploy_portworx_storage|bool
- name: create portworx node_group file
copy:
src: ./node_group.yaml
dest: ./node_group_pwx.yaml
when: deploy_portworx_storage|bool
- name: create portworx server_atomic file
copy:
src: ./server_atomic.yaml
dest: ./server_atomic_pwx.yaml
when: deploy_portworx_storage|bool
# Replace references to point to copied files
- name: specify pwx network template
replace:
path: openshift.yaml
regexp: 'network.yaml'
replace: 'network_pwx.yaml'
backup: yes
when: deploy_portworx_storage|bool
- name: specify pwx node_group template
replace:
path: openshift.yaml
regexp: 'node_group'
replace: 'node_group_pwx'
after: ' worker_small_nodes_deployment'
backup: yes
when: deploy_portworx_storage|bool
- name: specify pwx server_atomic template
replace:
path: node_group_pwx.yaml
regexp: 'server_atomic.yaml'
replace: 'server_atomic_pwx.yaml'
backup: yes
when: deploy_portworx_storage|bool
# Make edits in openshift.yaml
- name: add parameters to network stack
blockinfile:
dest: openshift.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts deploy_storage_networks parameter here"
marker: " # ANSIBLE MANAGED BLOCK - parameters for portworx deployment"
block: |2
# deploy portworx?
deploy_storage_networks: { get_param: deploy_portworx_storage }
when: deploy_portworx_storage|bool
- name: add storage networks parameters
blockinfile:
dest: openshift.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts {{ item }} tenant worker storage networks here"
marker: " # ANSIBLE MANAGED BLOCK - add_portworx_networks_parameters - worker-{{ item }}"
block: |2
extra_volumes: { get_param: deploy_portworx_storage }
storage_management_network: { get_attr: [internal_network, outputs, storage_management_network] }
storage_data_network: { get_attr: [internal_network, outputs, storage_data_network] }
loop: [ small, medium, large ]
when: deploy_portworx_storage|bool
- name: add storage networks parameters Net2
blockinfile:
dest: openshift.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts {{ item }} net2 worker storage networks here"
marker: " # ANSIBLE MANAGED BLOCK - add_portworx_networks_parameters Net2 - {{ purpose_ident }}-{{ item }}"
block: |2
extra_volumes: { get_param: deploy_portworx_storage }
storage_management_network: { get_attr: [internal_network, outputs, storage_management_network] }
storage_data_network: { get_attr: [internal_network, outputs, storage_data_network] }
loop: [ small, medium, large ]
when: deploy_portworx_storage|bool and multinetwork|bool
# - name: Change small worker size
# replace:
# path: openshift.yaml
# regexp: 'ocp.t1.xxlarge # add-portworx.yaml replaces this with pwx.t1.xxlarge'
# replace: 'pwx.t1.xxlarge'
# backup: yes
# when: deploy_portworx_storage|bool
- name: Change medium worker size
replace:
path: openshift.yaml
regexp: 'ocp.m1.large # add-portworx.yaml replaces this with pwx.m1.medium'
replace: 'pwx.m1.medium'
backup: yes
when: deploy_portworx_storage|bool
# - name: Change large worker size
# replace:
# path: openshift.yaml
# regexp: 'ocp.r1.large # add-portworx.yaml replaces this with pwx.r1.large'
# replace: 'pwx.r1.large'
# backup: yes
# when: deploy_portworx_storage|bool
# Make edits in network_pwx.yaml
- name: add storage networks parameters
blockinfile:
dest: network_pwx.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts deploy_storage_networks parameter here"
marker: " # ANSIBLE MANAGED BLOCK - add_portworx_networks_parameters"
block: |2
deploy_storage_networks:
type: boolean
default: false
when: deploy_portworx_storage|bool
- name: add storage networks
blockinfile:
dest: network_pwx.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts storage_networks resources here"
marker: " # ANSIBLE MANAGED BLOCK - add_portworx_networks_resources"
block: |2
storage_management_network:
type: OS::Neutron::Net
condition: deploy_storage_networks
properties:
admin_state_up: true
name: storage_management_network
storage_management_subnet:
type: OS::Neutron::Subnet
condition: deploy_storage_networks
properties:
name: storage_management_subnet
network: { get_resource: storage_management_network }
cidr: "10.254.253.0/24"
ip_version: 4
gateway_ip: ""
dns_nameservers: []
storage_data_network:
type: OS::Neutron::Net
condition: deploy_storage_networks
properties:
admin_state_up: true
name: storage_data_network
storage_data_subnet:
type: OS::Neutron::Subnet
condition: deploy_storage_networks
properties:
name: storage_data_subnet
network: { get_resource: storage_data_network }
cidr: "10.254.254.0/24"
ip_version: 4
gateway_ip: ""
dns_nameservers: []
conditions:
deploy_storage_networks:
get_param: deploy_storage_networks
when: deploy_portworx_storage|bool
- name: add storage networks outputs
blockinfile:
dest: network_pwx.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts storage_networks outputs here"
marker: " # ANSIBLE MANAGED BLOCK - add_portwox_networks_outputs"
block: |2
storage_data_network:
value: { get_resource: storage_data_network }
condition: deploy_storage_networks
storage_management_network:
value: { get_resource: storage_management_network }
condition: deploy_storage_networks
when: deploy_portworx_storage|bool
# Make edits in node_group_pwx.yaml
- name: node_group_parameters
blockinfile:
dest: node_group_pwx.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts network and volume parameters here"
marker: " # ANSIBLE MANAGED BLOCK - add parameters to node_group_pwx.yaml"
block: |2
extra_volumes:
type: boolean
description: Deploy extra volumes to non-infra nodes
default: false
storage_management_network:
type: string
description: Network for storage management traffic
storage_data_network:
type: string
description: Network for storage data traffic
when: deploy_portworx_storage|bool
- name: node_group_resources
blockinfile:
dest: node_group_pwx.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts server group parameters here"
marker: " # ANSIBLE MANAGED BLOCK - add properties to node_group server resources"
block: |2
extra_volumes: { get_param: extra_volumes }
storage_management_network: { get_param: storage_management_network }
storage_data_network: { get_param: storage_data_network }
when: deploy_portworx_storage|bool
# Make changes in server_atomic_pwx.yaml
- name: server_atomic parameters
blockinfile:
dest: server_atomic_pwx.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts atomic network and volume parameters here"
marker: " # ANSIBLE MANAGED BLOCK - add parameters to server_atomic_pwx.yaml"
block: |2
extra_volumes:
type: boolean
description: Deploy extra volumes to non-infra nodes
default: false
storage_management_network:
type: string
description: Network for storage management traffic
storage_data_network:
type: string
description: Network for storage data traffic
when: deploy_portworx_storage|bool
- name: server_atomic resources
blockinfile:
dest: server_atomic_pwx.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts server_atomic network resources here"
marker: " # ANSIBLE MANAGED BLOCK - add properties to server_atomic resources"
block: |2
- network: { get_param: storage_management_network }
- network: { get_param: storage_data_network }
when: deploy_portworx_storage|bool
- name: server_atomic storage resources
blockinfile:
dest: server_atomic_pwx.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts server_atomic volumes here"
marker: " # ANSIBLE MANAGED BLOCK - add properties to server_atomic resources"
block: |2
portworx_vol1:
type: OS::Cinder::Volume
condition: deploy_extra_volumes
properties:
description: Volume for kvdb
name:
str_replace:
template: vol_kvdb_servername_1
params:
servername: { get_param: server_name }
size: 100
volume_type: TIER2
vol_attachment_vol1:
type: OS::Cinder::VolumeAttachment
depends_on: [ server, portworx_vol1 ]
condition: deploy_extra_volumes
properties:
instance_uuid: { get_resource: server }
mountpoint: /dev/vdc
volume_id: { get_resource: portworx_vol1 }
portworx_vol2:
type: OS::Cinder::Volume
condition: deploy_extra_volumes
properties:
description: Volume for data
name:
str_replace:
template: vol_data_servername_1
params:
servername: { get_param: server_name }
size: 100
volume_type: TIER2
vol_attachment_vol2:
type: OS::Cinder::VolumeAttachment
depends_on: [ server, portworx_vol2, vol_attachment_vol1 ]
condition: deploy_extra_volumes
properties:
instance_uuid: { get_resource: server }
mountpoint: /dev/vdd
volume_id: { get_resource: portworx_vol2 }
conditions:
not_infra:
not:
equals:
- get_param: purpose_ident
- infra
deploy_volumes:
equals:
- get_param: extra_volumes
- true
deploy_extra_volumes:
and:
- not_infra
- deploy_volumes
when: deploy_portworx_storage|bool
- name: server_atomic - add code to wipe ephemeral disk
blockinfile:
dest: server_atomic_pwx.yaml
backup: yes
insertafter: "# add-portworx.yaml inserts extra code to wipe ephemeral disk here"
marker: " # ANSIBLE MANAGED BLOCK - add code to wipe ephemeral disk"
block: |2
EPHDEV="/dev/"`lsblk | grep /var/mnt | awk '{print $1}' | sed 's/[^a-z]*//g'`
sudo umount /mnt; sudo wipefs -af $EPHDEV
grep -v "${EPHDEV}" /etc/fstab > /tmp/fstab; sudo mv /tmp/fstab /etc/fstab
when: deploy_portworx_storage|bool