forked from cloudify-examples/drupal-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws-blueprint.yaml
673 lines (596 loc) · 19.5 KB
/
aws-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
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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
tosca_definitions_version: cloudify_dsl_1_3
imports:
- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
- http://www.getcloudify.org/spec/diamond-plugin/1.3.5/plugin.yaml
- http://www.getcloudify.org/spec/aws-plugin/1.4.3/plugin.yaml
- scale.yaml
inputs:
aws_access_key_id:
description: YOUR AWS ACCESS KEY ID
aws_secret_access_key:
description: YOUR AWS SECRET ACCESS KEY
ec2_region_name:
default: us-east-1
ec2_region_endpoint:
default: ec2.us-east-1.amazonaws.com
availability_zone:
default: us-east-1e
aws_config:
default:
aws_access_key_id: { get_input: aws_access_key_id }
aws_secret_access_key: { get_input: aws_secret_access_key }
ec2_region_name: { get_input: ec2_region_name }
ec2_region_endpoint: { get_input: ec2_region_endpoint }
vpc_id:
description: Your AWS Managers VPC.
vpc_cidr_block:
default: 172.16.0.0/16
public_subnet_id:
description: The public subnet in your VPC.
public_subnet_cidr:
default: 172.16.122.0/24
public_subnet_availability_zone:
default: { get_input: availability_zone }
private_subnet_id:
description: The private subnet in your VPC.
private_subnet_cidr:
default: 172.16.123.0/24
private_subnet_availability_zone:
default: { get_input: availability_zone }
key_name:
default: drupal
agent_private_key_path:
type: string
default: '~/.ssh/drupal.pem'
agent_user:
description: >
The username of the agent running on the instance created from the image.
default: 'ubuntu'
docRoot:
default: /var/www/html
dbPort:
default: 3306
dbBindAddress:
type: string
default: '0.0.0.0'
memcachePort:
default: 11211
# Ubuntu 14.04
image_id:
type: string
default: 'ami-c93a83de'
# RAM: 4096 MB, Hard Disk 80 GB, 2 vCPUs
instance_type:
type: string
default: 'm3.large'
drupal_security_group_name:
type: string
default: 'Drupal_AWS_Security_Group'
schemaurl:
type: string
default: 'http://repository.cloudifysource.org/org/cloudifysource/examples/drupal/new_babies7.zip'
drupalImageURL:
type:
default: 'http://repository.cloudifysource.org/org/cloudifysource/examples/drupal/babies_image_d7_v2.zip'
node_types:
###########################################################
# We define a type that inherits openstack's default
# server, and adds monitoring capabillities on top of it.
###########################################################
host:
derived_from: cloudify.aws.nodes.Instance
properties:
aws_config:
default: { get_input: aws_config }
image_id:
default: { get_input: image_id }
instance_type:
default: { get_input: instance_type }
parameters:
default:
placement: { get_property: [ private_subnet, availability_zone ] }
agent_config:
default:
install_method: remote
port: 22
user: { get_input: agent_user }
key: { get_input: agent_private_key_path }
interfaces:
utils.ops:
restart_vm_op: utils-scripts/restart_vm.sh
###########################################################
# We are infact telling cloudify to install a diamond
# monitoring agent on the server.
#
# (see https://github.com/BrightcoveOS/Diamond)
###########################################################
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
###########################################################
# Adding some collectors. These collectors are necessary
# for the Cloudify UI to display the deafult metrics.
###########################################################
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: {}
mysql_dbms:
derived_from: cloudify.nodes.DBMS
properties:
port:
description: MySQL port
type: integer
sectionNames:
description: A command separated list of my.cnf section names
type: string
variableNames:
description: A command separated list of my.cnf variable names
type: string
newValues:
description: A command separated list of my.cnf values for the above variable names
type: string
mysql_schema:
derived_from: cloudify.nodes.ApplicationModule
properties:
port:
description: MySQL port
type: integer
schemaurl:
description: schema zip url
type: string
query:
description: Test Query
type: string
memcached_db_server:
derived_from: cloudify.nodes.DBMS
properties:
port:
description: Memcached port
type: integer
memcached_application:
derived_from: cloudify.nodes.ApplicationModule
properties:
port:
description: Memcached port
type: integer
requiredmemory:
description: Required memory size in MB
type: integer
apache_server:
derived_from: cloudify.nodes.WebServer
properties:
base_port:
description: Web application port
type: integer
needPhp:
description: Does this application require php
type: string
needMemcache:
description: Does this application require memcache
type: string
dbType:
description: Database type that this application requires
type: string
num_instances:
description: Number of instances
type: integer
drupalVersion:
description: Drupal version
type: string
newPort:
description: Apache port
type: integer
docRoot:
description: docRoot of the Apache
type: string
drupal_application:
derived_from: cloudify.nodes.ApplicationModule
properties:
drupalImageURL:
description: Drupal image zip URL
type: string
app_name:
description: Application name
type: string
dbName:
description: Database name
type: string
dbUserName:
description: DB user name
type: string
dbUserPassword:
description: DB user password
type: string
docRoot:
description: docRoot of the Drupal
type: string
relationships:
drupal_server_connected_to_mysql_database:
derived_from: cloudify.relationships.connected_to
drupal_app_connected_to_mysql_drupal_schema:
derived_from: cloudify.relationships.connected_to
source_interfaces:
cloudify.interfaces.relationship_lifecycle:
postconfigure: drupal-scripts/configure-mysql-drupal.sh
target_interfaces:
cloudify.interfaces.relationship_lifecycle:
postconfigure: mysql-scripts/configure-mysql-schema.sh
drupal_app_connected_to_memcached_app:
derived_from: cloudify.relationships.connected_to
source_interfaces:
cloudify.interfaces.relationship_lifecycle:
establish: drupal-scripts/configure-memcached-drupal.sh
node_templates:
drupal_security_group:
type: cloudify.aws.nodes.SecurityGroup
properties:
aws_config: { get_input: aws_config }
resource_id: { get_input: drupal_security_group_name }
description: Security group for Cloudify Manager VM
rules:
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 8080
to_port: 8080
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 8000
to_port: 8000
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 8081
to_port: 8081
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 22
to_port: 22
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 80
to_port: 80
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 3306
to_port: 3306
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 55672
to_port: 55672
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 5672
to_port: 5672
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 53229
to_port: 53229
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 8101
to_port: 8101
- ip_protocol: tcp
cidr_ip: 0.0.0.0/0
from_port: 8100
to_port: 8100
relationships:
- type: cloudify.aws.relationships.security_group_contained_in_vpc
target: vpc
apache_ip:
type: cloudify.aws.nodes.ElasticIP
properties:
aws_config: { get_input: aws_config }
domain: vpc
capabilities:
scalable:
properties:
default_instances: 1
relationships:
- type: cloudify.relationships.contained_in
target: vpc
mysql_vm:
type: host
relationships:
- type: cloudify.aws.relationships.instance_connected_to_security_group
target: drupal_security_group
- type: cloudify.aws.relationships.instance_connected_to_subnet
target: private_subnet
- type: cloudify.aws.relationships.instance_connected_to_keypair
target: key
memcached_vm:
type: host
relationships:
- type: cloudify.aws.relationships.instance_connected_to_security_group
target: drupal_security_group
- type: cloudify.aws.relationships.instance_connected_to_subnet
target: private_subnet
- type: cloudify.aws.relationships.instance_connected_to_keypair
target: key
apache_vm:
type: host
properties:
parameters:
placement: { get_property: [ public_subnet, availability_zone ] }
relationships:
- type: cloudify.relationships.contained_in
target: vpc
- type: cloudify.aws.relationships.instance_connected_to_security_group
target: drupal_security_group
- type: cloudify.aws.relationships.instance_connected_to_subnet
target: public_subnet
- type: cloudify.aws.relationships.instance_connected_to_keypair
target: key
- target: apache_ip
type: cloudify.aws.relationships.instance_connected_to_elastic_ip
mysql_database:
type: mysql_dbms
properties:
port: { get_input: dbPort }
sectionNames: mysqld
variableNames: bind-address
newValues: 0.0.0.0
interfaces:
cloudify.interfaces.lifecycle:
create: mysql-scripts/install-mysql-aws.sh
start: mysql-scripts/start-mysql.sh
stop: mysql-scripts/stop-mysql.sh
relationships:
- target: mysql_vm
type: cloudify.relationships.contained_in
mysql_drupal_schema:
type: mysql_schema
properties:
port: { get_input: dbPort }
query: select name,mail from users
schemaurl: { get_input: schemaurl }
interfaces:
cloudify.interfaces.lifecycle:
configure: mysql-scripts/configure-mysql-schema.sh
cloudify.interfaces.monitoring:
start:
implementation: diamond.diamond_agent.tasks.add_collectors
inputs:
collectors_config:
MySQLCollector:
config:
enabled: True
hosts: "admin:123@localhost:3306/mydrupaldb"
relationships:
- target: mysql_database
type: cloudify.relationships.contained_in
memcached_server:
type: memcached_db_server
properties:
port: { get_input: memcachePort }
interfaces:
cloudify.interfaces.lifecycle:
create: memcached-scripts/install-memcached.sh
configure: memcached-scripts/configure-memcached.sh
relationships:
- target: memcached_vm
type: cloudify.relationships.contained_in
memcached_app:
type: memcached_application
properties:
port: { get_input: memcachePort }
requiredmemory: 1000
interfaces:
cloudify.interfaces.lifecycle:
start: memcached-scripts/start-memcached.sh
stop: memcached-scripts/stop-memcached.sh
relationships:
- target: memcached_server
type: cloudify.relationships.contained_in
drupal_server:
type: apache_server
properties:
base_port: 8080
num_instances: 1
needPhp: yesplease
needMemcache: yesplease
dbType: mysql
drupalVersion: 7
newPort: 80
docRoot: { get_input: docRoot }
interfaces:
cloudify.interfaces.lifecycle:
create: apache-scripts/install-apache.sh
relationships:
- type: cloudify.relationships.contained_in
target: apache_vm
- type: drupal_server_connected_to_mysql_database
target: mysql_database
drupal_app:
type: drupal_application
properties:
docRoot: { get_input: docRoot }
drupalImageURL: { get_input: drupalImageURL }
app_name: My drupal web server
dbName: mydrupaldb
dbUserName: admin
dbUserPassword: 123
interfaces:
cloudify.interfaces.lifecycle:
start: apache-scripts/start-apache.sh
stop: apache-scripts/stop-apache.sh
drupal.interfaces.action:
install_project: drupal-scripts/drush-install.sh
set_variable: drupal-scripts/drush-setvar.sh
relationships:
- type: cloudify.relationships.contained_in
target: drupal_server
- type: drupal_app_connected_to_memcached_app
target: memcached_app
- type: drupal_app_connected_to_mysql_drupal_schema
target: mysql_drupal_schema
public_subnet:
type: cloudify.aws.nodes.Subnet
properties:
aws_config: { get_input: aws_config }
use_external_resource: true
resource_id: { get_input: public_subnet_id }
cidr_block: { get_input: public_subnet_cidr }
availability_zone: { get_input: public_subnet_availability_zone }
relationships:
- type: cloudify.aws.relationships.subnet_contained_in_vpc
target: vpc
private_subnet:
type: cloudify.aws.nodes.Subnet
properties:
aws_config: { get_input: aws_config }
use_external_resource: true
resource_id: { get_input: private_subnet_id }
cidr_block: { get_input: private_subnet_cidr }
availability_zone: { get_input: private_subnet_availability_zone }
relationships:
- type: cloudify.aws.relationships.subnet_contained_in_vpc
target: vpc
vpc:
type: cloudify.aws.nodes.VPC
properties:
aws_config: { get_input: aws_config }
use_external_resource: true
resource_id: { get_input: vpc_id }
cidr_block: { get_input: vpc_cidr_block }
key:
type: cloudify.aws.nodes.KeyPair
properties:
aws_config: { get_input: aws_config }
resource_id: { get_input: key_name }
private_key_path: { get_input: agent_private_key_path }
plugins:
drush-plugin:
executor: central_deployment_agent
source: drush-plugin
utils-plugin:
executor: central_deployment_agent
source: utils-plugin
workflows:
restart_vms:
mapping: utils-plugin.vms.tasks.restart_vms
parameters:
node_id:
description: The node id whose instance will be restarted
node_instance_id:
description: The node instance id which will be restarted - default(null) = All instances...
default: null
my_input:
description: Additional input
default: null
drush_install:
mapping: drush-plugin.drush.tasks.install_project
parameters:
project_name: {}
# See Built-in Workflows in http://getcloudify.org/guide/3.3.1/guide-workflows.html#built-in-workflows
# drushinstall:
# mapping: default_workflows.cloudify.plugins.workflows.execute_operation
# parameters:
# operation: drupal.interfaces.action.install_project
# node_ids:
# - drupal_app
drush_setvar:
mapping: drush-plugin.drush.tasks.set_variable
parameters:
variable_name:
default: theme_default
variable_value: {}
# Syntax without parameters
# drush_dl: drush-plugin.drush.tasks.drush_download_module
# drush_en: drush-plugin.drush.tasks.drush_enable_module
outputs:
endpoint:
description: My application endpoint
value:
drupal_url: { concat: ['http://', { get_attribute: [apache_vm, public_ip_address] },':', { get_property: [drupal_server, newPort] }] }
groups:
scale_up_group:
members: [apache_vm]
policies:
auto_scale_up:
type: scale_policy_type
properties:
default_instances: 1
# If there is more than one member and policy_operates_on_group is set to true,
# then the threshold is checked against the SUM of all the relevant metrics from all the memebers.
# E.g.:
# policy_operates_on_group is set to true and the members are aaa,bbb and ccc
# threshold is 10
# aaa has 3, bbb has 4 and ccc is 5, then together they are more than 10 , hence the threshold will be breached.
# if policy_operates_on_group is set to false, then if and only if at least one of them (aaa,bbb or ccc) is greater than 10, the threshold will be breached.
policy_operates_on_group: true
scale_limit: 5
scale_direction: '<'
scale_threshold: 40
service_selector: .*apache_vm.*.cpu.total.user
cooldown_time: 60
triggers:
execute_scale_workflow:
type: cloudify.policies.triggers.execute_workflow
parameters:
workflow: scale
workflow_parameters:
delta: 1
scalable_entity_name: apache
# scale_compute: true
scale_down_group:
members: [apache_vm]
policies:
auto_scale_down:
type: scale_policy_type
properties:
default_instances: 1
scale_limit: 2
scale_direction: '>'
scale_threshold: 20
service_selector: .*apache_vm.*.cpu.total.user
cooldown_time: 60
triggers:
execute_scale_workflow:
type: cloudify.policies.triggers.execute_workflow
parameters:
workflow: scale
workflow_parameters:
delta: -1
scalable_entity_name: apache
# scale_compute: true
heal_group:
members: [memcached_vm]
policies:
simple_autoheal_policy:
type: cloudify.policies.types.host_failure
properties:
service: ['cpu.total.user']
#- .*memcached-vm.*.cpu.total.user
interval_between_workflows: 60
triggers:
auto_heal_trigger:
type: cloudify.policies.triggers.execute_workflow
parameters:
workflow: heal
workflow_parameters:
node_instance_id: { 'get_property': [ SELF, node_id ] }
diagnose_value: { 'get_property': [ SELF, diagnose ] }
apache:
members: [apache_vm, apache_ip]
policies:
scale_policy1:
type: cloudify.policies.scaling
properties:
default_instances: 1
targets: [apache]