forked from EarthmanT/cloudify-nodecellar-docker-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws-ec2-blueprint.yaml
208 lines (188 loc) · 5.96 KB
/
aws-ec2-blueprint.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
tosca_definitions_version: cloudify_dsl_1_3
imports:
- http://www.getcloudify.org/spec/cloudify/3.5m1/types.yaml
- http://www.getcloudify.org/spec/aws-plugin/1.4.1/plugin.yaml
- http://www.getcloudify.org/spec/docker-plugin/1.3.2/plugin.yaml
- http://www.getcloudify.org/spec/diamond-plugin/1.3.4/plugin.yaml
- types/nodecellar.yaml
inputs:
image:
description: >
The AWS AWI ID
size:
description: >
The AWS instance type
agent_user:
description: >
User name used when SSH-ing into the started machine
default: ubuntu
web_port:
description: >
Which port you want to map the web port to.
default: 8080
mongo_port:
description: >
Which port you want to map the mongo port to.
default: 27017
web_status_port:
description: >
Which port for the mongo web status page.
default: 28017
nodecellar_container_port_bindings:
description: >
A dict of port bindings for the node container.
default:
8080: 8080
mongo_container_port_bindings:
description: >
A dict of port bindings for the mongo container.
default:
27017: 27017
28017: 28017
node_types:
nodecellar.nodes.MonitoredDockerHost:
derived_from: cloudify.aws.nodes.Instance
properties:
cloudify_agent:
default:
user: { get_input: agent_user }
home_dir: /home/ubuntu
parameters:
default:
user_data: |
#!/bin/bash
sudo service ssh stop
curl -o install.sh -sSL https://get.docker.com/
sudo sh install.sh
sudo groupadd docker
sudo gpasswd -a ubuntu docker
sudo service docker restart
sudo service ssh start
interfaces:
cloudify.interfaces.monitoring_agent:
install:
implementation: diamond.diamond_agent.tasks.install
inputs:
diamond_config:
default:
interval: 1
start: diamond.diamond_agent.tasks.start
stop: diamond.diamond_agent.tasks.stop
uninstall: diamond.diamond_agent.tasks.uninstall
cloudify.interfaces.monitoring:
start:
implementation: diamond.diamond_agent.tasks.add_collectors
inputs:
collectors_config:
default:
CPUCollector: {}
MemoryCollector: {}
LoadAverageCollector: {}
DiskUsageCollector:
config:
devices: x?vd[a-z]+[0-9]*$
NetworkCollector: {}
node_templates:
nodecellar_elasticip:
type: cloudify.aws.nodes.ElasticIP
mongod_security_group:
type: cloudify.aws.nodes.SecurityGroup
properties:
description: MongoDBSecGroup
rules:
- ip_protocol: tcp
from_port: 22
to_port: 22
cidr_ip: 0.0.0.0/0
- ip_protocol: tcp
from_port: { get_input: mongo_port }
to_port: { get_input: mongo_port }
cidr_ip: 0.0.0.0/0
- ip_protocol: tcp
from_port: { get_input: web_status_port }
to_port: { get_input: web_status_port }
cidr_ip: 0.0.0.0/0
nodecellar_security_group:
type: cloudify.aws.nodes.SecurityGroup
properties:
description: NodeJSSecGroup
rules:
- ip_protocol: tcp
from_port: 22
to_port: 22
cidr_ip: 0.0.0.0/0
- ip_protocol: tcp
from_port: { get_input: web_port }
to_port: { get_input: web_port }
cidr_ip: 0.0.0.0/0
mongo_vm:
type: nodecellar.nodes.MonitoredDockerHost
properties:
image_id: { get_input: image }
instance_type: { get_input: size }
relationships:
- type: cloudify.aws.relationships.instance_connected_to_security_group
target: mongod_security_group
node_vm:
type: nodecellar.nodes.MonitoredDockerHost
properties:
image_id: { get_input: image }
instance_type: { get_input: size }
relationships:
- type: cloudify.aws.relationships.instance_connected_to_security_group
target: nodecellar_security_group
- type: cloudify.aws.relationships.instance_connected_to_elastic_ip
target: nodecellar_elasticip
mongod_container:
type: nodecellar.nodes.MongoContainer
interfaces:
cloudify.interfaces.lifecycle:
create:
inputs:
params:
ports:
- { get_input: mongo_port }
- { get_input: web_status_port }
stdin_open: true
tty: true
command: mongod --rest --httpinterface --smallfiles
start:
inputs:
params:
port_bindings: { get_input: mongo_container_port_bindings }
relationships:
- type: cloudify.relationships.contained_in
target: mongo_vm
nodecellar_container:
type: nodecellar.nodes.NodecellarContainer
interfaces:
cloudify.interfaces.lifecycle:
create:
inputs:
params:
ports:
- { get_input: web_port }
stdin_open: true
tty: true
command: nodejs server.js
environment:
NODECELLAR_PORT: { get_input: web_port }
MONGO_PORT: { get_input: mongo_port }
MONGO_HOST: { get_property: [ mongod_container, name ] }
start:
inputs:
params:
port_bindings: { get_input: nodecellar_container_port_bindings }
extra_hosts:
mongod: { get_attribute: [ mongo_vm, ip ] }
relationships:
- type: cloudify.relationships.contained_in
target: node_vm
- type: cloudify.relationships.depends_on
target: mongod_container
outputs:
endpoint:
description: Web application endpoint
value:
ip_address: { get_attribute: [ nodecellar_elasticip, aws_resource_id ] }
port: { get_input: web_port }