-
Notifications
You must be signed in to change notification settings - Fork 0
/
2-deploy-vm-createvol.yaml
85 lines (77 loc) · 2.42 KB
/
2-deploy-vm-createvol.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
heat_template_version: 2014-10-16
description: a template to deploy two compute instances (CentOS7) \
- one for web frontend \
- another for db backend with a new volume
parameters:
key_name:
type: string
label: Key Name
description: Name of key-pair to be used for compute instance
default: son-key
image_id:
type: string
label: Image ID
description: Image to be used for compute instance
default: centos6
instance_type:
type: string
label: Instance Type
description: Type of instance (flavor) to be used
default: fl.default
constraints:
- allowed_values: [ fl.default, fl.large, fl.xlarge, fl.huge ]
description: Value must be one of m1.medium, m1.large or m1.xlarge
resources:
my_web_instance:
type: OS::Nova::Server
properties:
networks:
- network: net-ptin
key_name: { get_param: key_name }
image: { get_param: image_id }
flavor: { get_param: instance_type }
my_db_instance:
type: OS::Nova::Server
properties:
networks:
- network: net-ptin
key_name: { get_param: key_name }
image: { get_param: image_id }
flavor: { get_param: instance_type }
user_data_format: RAW
user_data:
str_replace:
template: |
#cloud-config
write_files:
- content: |
#!/bin/bash
voldata_id="%voldata_id%"
voldata_dev="/dev/disk/by-uuid/virtio-$(echo ${voldata_id} | cut -c -20)"
mkfs.ext4 ${voldata_dev}
mkdir -pv /opt/apps
echo "${voldata_dev} /opt/apps ext4 defaults 1 2" >> /etc/fstab
mount /opt/apps
path: /tmp/format-disks
permissions: '0700'
runcmd:
- /tmp/format-disks
params:
"%voldata_id%": { get_resource: db_volume2 }
db_volume2:
type: OS::Cinder::Volume
properties:
size: 6
db_vol_attach:
type: OS::Cinder::VolumeAttachment
properties:
instance_uuid: { get_resource: my_db_instance }
volume_id: { get_resource: db_volume2 }
mountpoint: /dev/vdb
outputs:
www_instance_ip:
description: the IP address of the instance
value: { get_attr: [my_web_instance, first_address] }
db_instance_ip:
description: the IP address of the instance
value: { get_attr: [my_db_instance, first_address] }