-
Notifications
You must be signed in to change notification settings - Fork 1
/
db2.yaml
471 lines (418 loc) · 17.2 KB
/
db2.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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
heat_template_version: 2013-05-23
description: >
Single DB2 deployment
parameters:
############################
# Server parameters
############################
flavor:
type: string
description: Flavor to be used for compute instance
label: Flavor
constraints:
- custom_constraint: nova.flavor
key_name:
type: string
description: 'For most clouds, the name of the key-pair to be used for the compute instance; for VMware clouds, the contents of the public SSH key for the compute instance'
label: SSH Key name
constraints:
- custom_constraint: nova.keypair
network-id__for__patterns-service-dev-net:
type: string
description: 'Generated to reference ''patterns-service-dev-net'' network.'
default: 'fbd19302-f247-4816-b53e-a664f3dc72c1'
subnet_id_46fcd6d7-017e-437b-9921-d7fb9f76a7f2:
type: string
description: 'Generated to reference subnet ''46fcd6d7-017e-437b-9921-d7fb9f76a7f2''.'
default: '46fcd6d7-017e-437b-9921-d7fb9f76a7f2'
public_network_id:
type: string
description: 'Generated for floating IP'
default: 'public_network_id'
security_group:
type: string
description: 'Name of the security group'
default: 'default'
availability_zone:
type: string
description: 'Name of availability zone in which to create the instance'
label: Availability zone
default: 'nova'
image_id:
type: string
description: OS Image to deploy onto
label: OS Image
constraints:
- custom_constraint: glance.image
root_password:
description: This is the password for the root user of the system
label: Password (root)
hidden: True
type: string
virtuser_password:
description: This is the password for the virtuser user of the system
label: Password (virtuser)
hidden: True
type: string
sw_repo_root:
default: 'http://159.122.222.80/sw_repo/'
description: Software repository URL
label: Software Repository URL
type: string
############################
# Salt Specific Parameters
############################
salt_master_address:
type: string
description: Hostname/IP address of the salt-master, leave blank to use metadata.yaml
label: Saltmaster address
default: ''
salt_api_token:
type: string
description: Security token for connecting to Salt API
label: Salt api token
hidden: True
############################
# Server names
############################
hostname_db2:
type: string
description: DB2 Server hostname
label: Server hostname
default: db2srv01
############################
# DB2 parameters
############################
instanceowner_name:
type: string
description: Instanceowner username
label: Instance owner username
default: db2inst1
fenced_name:
type: string
description: Fenced username
label: Fenced user username
default: db2fenc1
database_name:
type: string
description: Name of the database to be created
label: Database name
default: sampledb
database_datamountpoint:
type: string
description: Mountpoint for the database within the instances filesystem
label: Data mountpoint
default: /db2
database_codeset:
type: string
description: Specifies the code set to be used for data entered into this database. After you create the database, you cannot change the specified code set.
label: Codeset
default: UTF-8
constraints:
- allowed_values: [UTF-8,ISO8859-1,ISO8859-2,ISO8859-5,ISO8859-6,ISO8859-7,ISO8859-8,ISO8859-9,ISO8859-15,ISO-8859-1,ISO-8859-2,ISO-8859-7,ISO-8859-8,ISO-8859-9,ISO-8859-15,iso88591,iso88592,iso88595,iso88596,iso88597,iso88599,iso885915,IBM-37,IBM-273,IBM-274,IBM-277,IBM-278,IBM-280,IBM-284,IBM-285,IBM-297,IBM-420,IBM-423,IBM-424,IBM-425,IBM-437,IBM-500,IBM-806,IBM-838,IBM-850,IBM-852,IBM-855,IBM-856,IBM-857,IBM-862,IBM-863,IBM-864,IBM-866,IBM-869,IBM-870,IBM-871,IBM-875,IBM-921,IBM-922,IBM-930,IBM-932,IBM-933,IBM-935,IBM-937,IBM-938,IBM-939,IBM-942,IBM-943,IBM-948,IBM-949,IBM-1025,IBM-1026,IBM-1046,IBM-1112,IBM-1122,IBM-1123,IBM-1124,IBM-1125,IBM-1129,IBM-1130,IBM-1131,IBM-1140,IBM-1141,IBM-1142,IBM-1143,IBM-1144,IBM-1145,IBM-1146,IBM-1147,IBM-1148,IBM-1149,IBM-1153,IBM-1154,IBM-1155,IBM-1156,IBM-1157,IBM-1158,IBM-1160,IBM-1164,IBM-1364,IBM-1371,IBM-1381,IBM-1388,IBM-5026,IBM-eucCN,IBM-eucJP,IBM-eucKR,IBM-eucTW,eucCN,eucJP,eucKR,eucTW,hp15CN]
database_territory:
type: string
description: Specifies the territory identifier or locale identifier to be used for data entered into this database. After you create the database, you cannot change the specified territory. The combination of the code set and territory or locale values must be valid.
label: Territory
default: US
constraints:
- allowed_values: [US,AL,AA,AU,AT,AZ,BY,BE,BG,BR,CA,CN,HR,CZ,DK,EE,FI,MK,FR,DE,GR,HK,HU,IS,IN,ID,IE,IL,IT,JP,KZ,KR,Lat,LV,LT,MY,MT,ME,NL,NZ, NO,PK,PL,PT,RO,RU,SP,SK,SI,ZA,ES,SE,CH,TW,TH,TR,GB,UA,VN]
database_collate:
type: string
description: the type of collating sequence to be used for the database. Once the database has been created, the collating sequence cannot be changed.
label: Collaction
default: SYSTEM
constraints:
- allowed_values: [SYSTEM,COMPATIBILITY,IDENTIT,IDENTITY_16BIT,UCA400_NO,UCA400_LSK,UCA400_LTH]
database_pagesize:
type: string
description: Page size of the default buffer pool along with the initial table spaces (SYSCATSPACE, TEMPSPACE1, USERSPACE1) when the database is created.
label: Pagesize
default: 4096
constraints:
- allowed_values: [4096,8192,16384,32768]
parameter_groups:
- { label: 'DB2 Database Parameters', parameters: [instanceowner_name, fenced_name, database_name, database_datamountpoint, database_codeset, database_territory, database_collate, database_pagesize] }
- { label: 'Host Name Parameters', parameters: [hostname_db2] }
- { label: 'Image Parameters', parameters: [flavor, key_name, availability_zone, image_id, virtuser_password, root_password, sw_repo_root] }
- { label: 'Hidden Parameters', parameters: [salt_master_address, salt_api_token] }
- { label: 'Network Parameters', parameters: [network-id__for__patterns-service-dev-net, subnet_id_46fcd6d7-017e-437b-9921-d7fb9f76a7f2, public_network_id, security_group] }
resources:
db2_wait_handle:
type: "AWS::CloudFormation::WaitConditionHandle"
db2_wait_condition:
depends_on: db2
type: "AWS::CloudFormation::WaitCondition"
properties:
Handle: { get_resource: db2_wait_handle }
Timeout: 3600
############################
# DB2 Server
############################
db2:
type: OS::Nova::Server
properties:
networks:
- port: { get_resource: rhel-7_2-2015-12-13__to__patterns-service-dev-net__port }
name: { get_param: hostname_db2 }
image: { get_param: image_id }
flavor: { get_param: flavor }
availability_zone: { get_param: availability_zone }
key_name: { get_param: key_name }
user_data_format: RAW
user_data: { get_resource: db2_init }
rhel-7_2-2015-12-13__to__patterns-service-dev-net__port__floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: { get_param: public_network_id }
port_id: { get_resource: rhel-7_2-2015-12-13__to__patterns-service-dev-net__port }
rhel-7_2-2015-12-13__to__patterns-service-dev-net__port:
type: OS::Neutron::Port
properties:
network_id: { get_param: network-id__for__patterns-service-dev-net }
replacement_policy: AUTO #TODO remove this if using HEAT version Icehouse!
fixed_ips:
- subnet: { get_param: subnet_id_46fcd6d7-017e-437b-9921-d7fb9f76a7f2 }
security_groups: [{ get_param: security_group }]
db2_init:
type: OS::Heat::MultipartMime
properties:
parts:
- config: { get_resource: fix_logind }
- config: { get_resource: setup_ssh }
- config: { get_resource: bootstrap_salt }
- config: { get_resource: assign_roles }
- config: { get_resource: create_pillar_file }
- config: { get_resource: run_orchestration }
- config: { get_resource: zeron_config }
assign_roles:
type: "OS::Heat::SoftwareConfig"
properties:
config:
str_replace:
template: |
#!/usr/bin/env bash
set -e
cat > /etc/salt/grains << EOF
environment:
$ENV
pattern:
$WORKLOAD_AUTOMATION
roles:
- $ROLES_1
stack:
$STACK_ID
EOF
sleep 30
service salt-minion stop
sleep 15
service salt-minion start
params:
$ENV: base
$WORKLOAD_AUTOMATION: ibm_db2
$ROLES_1: ibm_db2_v10x_linux
$STACK_ID: { get_param: "OS::stack_id" }
create_pillar_file:
type: OS::Heat::CloudConfig
properties:
cloud_config:
write_files:
- path: /tmp/pillar.yaml
content:
str_replace:
template: |
ibm:
sw_repo_root: $SW_REPO_ROOT
db2:
v10x:
users:
$INSTANCEOWNER_NAME:
password: $6$mn0q55HU$uXeOS6FPtAZcS8xlx97SBjVlvdcD3nmGy0YUqsMNscB7qFKWAd2DKV2zOPXj2BmLGCqfjJpEEbqr4JAwN4l.f.
$FENCED_NAME:
password: $6$St12FUju$QrsEPqLm1GYjCcy5p3vZ3q6fptc3pQPL0ZAFXLjcBVEc2REWNS/gQDmmTLuDg7HnSlKPLj9rRtC0ESftw60Vv0
instances:
$INSTANCEOWNER_NAME:
fenced_user: $FENCED_NAME
databases:
$DATABASE_NAME:
create_params:
PATH: $PATH
CODESET: $CODESET
TERRITORY: $TERRITORY
COLLATE: $COLLATE
PAGETSIZE: $PAGESIZE
params:
LOGARCHMETH1: LOGRETAIN
params:
$SW_REPO_ROOT: {get_param: sw_repo_root }
$WORKLOAD_AUTOMATION: bluemix_db2_single
$INSTANCEOWNER_NAME: { get_param: instanceowner_name }
$FENCED_NAME: { get_param: fenced_name }
$DATABASE_NAME: { get_param: database_name }
$DATABASE_TYPE: DM
$PATH: { get_param: database_datamountpoint }
$CODESET: { get_param: database_codeset }
$TERRITORY: { get_param: database_territory }
$COLLATE: { get_param: database_collate }
$PAGESIZE: { get_param: database_pagesize }
run_orchestration:
type: "OS::Heat::SoftwareConfig"
properties:
config:
str_replace:
template: |
#!/usr/bin/env bash
set -e
/opt/saltstack/embedded/bin/salt-wrapper.py orchestrate_heat dummyUser dummyPass \
--environment $ENV \
--automation $WORKLOAD_AUTOMATION \
--orchestration $ORCHESTRATION \
--wait_url '$WAIT_URL' \
--stack_id $STACK_ID \
--pillar_file /tmp/pillar.yaml \
--pillar stack_id=$STACK_ID \
--reactor_flask \
--salt_token $SALT_API_TOKEN
echo " /opt/saltstack/embedded/bin/salt-wrapper.py orchestrate_heat dummyUser dummyPass \
--environment $ENV \
--automation $WORKLOAD_AUTOMATION \
--orchestration $ORCHESTRATION \
--wait_url '$WAIT_URL' \
--stack_id $STACK_ID \
--pillar_file /tmp/pillar.yaml \
--pillar stack_id=$STACK_ID" \
--reactor_flask \
--salt_token $SALT_API_TOKEN >> /tmp/test
params:
$SALT_API_TOKEN: { get_param: salt_api_token}
$ENV: base
$WORKLOAD_AUTOMATION: ibm_db2
$ORCHESTRATION: ibm_db2_zeron
$STACK_ID: { get_param: "OS::stack_id" }
$WAIT_URL: { get_resource: db2_wait_handle }
zeron_config:
type: "OS::Heat::SoftwareConfig"
properties:
config:
str_replace:
params:
$INSTANCE: { get_param: instanceowner_name }
template: |
#!/usr/bin/env bash
set -e
mkdir -p /etc/IBM/zeron/services/inventory/db2/server/
cat > /etc/IBM/zeron/services/inventory/db2/server/inventory.json << EOF
{
"product_name" : "IBM DB2 Standalone Server",
"product_version" : "10.5.0.7",
"attributes" : {
}
}
EOF
mkdir -p /etc/IBM/zeron/services/logging/db2/server/
cat > /etc/IBM/zeron/services/logging/db2/server/logging.json << EOF
[
{
"type" : "dir",
"name" : "DB2 Server",
"path" : "/home/$INSTANCE/sqllib/db2dump/",
"pattern" : "*.log"
}
]
EOF
############################
# General Scripts
############################
bootstrap_salt:
type: "OS::Heat::SoftwareConfig"
properties:
config:
str_replace:
template: |
#!/usr/bin/env bash
set -e
if [ -f /etc/redhat-release ]; then
rpm -Uvh "http://159.122.222.80/sw_repo/salt/saltstack-latest-el$(rpm -qf --qf "%{VERSION}" /etc/redhat-release | cut -c1).x86_64.rpm"
elif [ -f /etc/lsb-release ]; then
curl "http://159.122.222.80/sw_repo/salt/saltstack-latest-trusty.x86_64.deb" -O
dpkg -i saltstack-latest-trusty.x86_64.deb
update-rc.d salt-minion start 80 2 3 4 5 .
fi
#chkconfig salt-minion on
mkdir -p /etc/salt/pki/minion
# retrieve saltMaster address from metadata if not passed
saltMaster=$SALT_MASTER
echo "master"$saltMaster >> /tmp/master
token=$SALT_API_TOKEN
echo "token"$token >> /tmp/master
if [ -z $saltMaster ] ; then
echo "no master" >> /tmp/master
saltMaster=$(curl -s http://159.122.222.80/sw_repo//metadata.yaml | awk '/salt_api_ip/ {print $2}')
fi
# Default log_level warning
cat > /etc/salt/minion << EOF
log_level: warning
master:
- $saltMaster
id: $STACK_ID-`hostname -s`
mine_functions:
network.interfaces: []
grains.items: []
mine_interval: 1
EOF
service salt-minion stop
sleep 10
service salt-minion start
sleep 30
wget http://159.122.222.80/sw_repo/salt/salt-wrapper.py -O /opt/saltstack/embedded/bin/salt-wrapper.py
/opt/saltstack/embedded/bin/salt-wrapper.py register dummyUser dummyPass -k $SALT_API_TOKEN
params:
$STACK_ID: { get_param: "OS::stack_id" }
$SALT_MASTER: { get_param: salt_master_address }
$SALT_API_TOKEN: { get_param: salt_api_token }
setup_ssh:
type: "OS::Heat::SoftwareConfig"
properties:
config:
str_replace:
template: |
#!/usr/bin/env bash
# add virtuser
set -e
useradd -m virtuser
mkdir -p /home/virtuser/.ssh
chown virtuser.virtuser /home/virtuser/.ssh
chmod 700 /home/virtuser/.ssh
# set the password for root and virtuser
echo virtuser:$USER_PWD | chpasswd
echo root:$ROOT_PWD | chpasswd
# setup sshd configuration
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -e "/PasswordAuthentication/d" /etc/ssh/sshd_config > /etc/ssh/sshd_config.tmp
cat /etc/ssh/sshd_config.tmp > /etc/ssh/sshd_config
rm -f /etc/ssh/sshd_config.tmp
echo $'\n' >> /etc/ssh/sshd_config
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
service sshd restart
params:
$USER_PWD: { get_param: virtuser_password}
$ROOT_PWD: { get_param: root_password}
fix_logind:
type: "OS::Heat::SoftwareConfig"
properties:
config: |
#!/usr/bin/env bash
set -e
# script introduced to get round RHEL 7.2 bug causing problems with DB2.
# https://bugzilla.redhat.com/show_bug.cgi?id=1264533
echo $'\n' >> /etc/systemd/logind.conf
echo RemoveIPC=no >> /etc/systemd/logind.conf
systemctl restart systemd-logind
outputs:
db2server:
description: Address of the db2 server
value:
str_replace:
params:
$IPADDR: { get_attr: [rhel-7_2-2015-12-13__to__patterns-service-dev-net__port__floating_ip, floating_ip_address] }
template: Server IP $IPADDR