-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi.rb
118 lines (105 loc) · 3.42 KB
/
multi.rb
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
# encoding: utf-8
name "stefhen-multi-tier"
rs_ca_ver "20131202"
short_description "3 Tier App"
long_description "Basic 3-Tier stack"
mapping "clouds" do {
"EC2 us-west-2" => {
"cloud_href" => "/api/clouds/6",
"us-west-2a" => "/api/clouds/6/datacenters/BAJJAFGMFRO5G",
"c1.medium" => "/api/clouds/6/instance_types/1GFPQQ2KVKM",
"m1.small" => "/api/clouds/6/instance_types/1BH7SA9LMLFSV",
"security_group" => "/api/clouds/6/security_groups/A68GO1Q5B9GJF",
"ssh_key" => "/api/clouds/6/ssh_keys/EDTM9LCHDNBBL" },
"EC2 us-east-1" => {
"cloud_href" => "/api/clouds/1",
"us-east-1a" => "/api/clouds/1/datacenters/ATV0391A7LPF5",
"c1.medium" => "/api/clouds/1/instance_types/6U7NRRI3I0UM",
"m1.small" => "/api/clouds/1/instance_types/CQQV62T389R32",
"security_group" => "/api/clouds/1/security_groups/FJK0P7V5JIJ12",
"ssh_key" => "/api/clouds/1/ssh_keys/13FIKG64LL5SG" }
}
end
parameter "cloud" do
type "string"
label "Cloud"
description "Which cloud do you wish to use?"
allowed_values "EC2 us-west-2", "EC2 us-east-1"
end
parameter "datacenter" do
type "string"
label "Datacenter"
description "Datacenter to use"
allowed_values "us-west-2a", "us-east-1a"
end
parameter "instance_type" do
type "string"
label "Instance type"
description "Instance size to use"
allowed_values "m1.small", "c1.medium"
end
parameter "branch" do
type "string"
label "git branch"
description "Git branch to clone"
allowed_values "master", "PSST-60-GlusterMC"
end
resource "load_balancer", type: "server" do
name "Load Balancer"
cloud_href map($clouds, $cloud, "cloud_href")
datacenter_href map($clouds, $cloud, $datacenter)
instance_type_href map($clouds, $cloud, $instance_type)
security_groups_href map($clouds, $cloud, "security_group")
ssh_key_href map($clouds, $cloud, "ssh_key")
server_template_href("/api/server_templates/336538003")
end
resource "app_array", type: "server_array" do
name "stefhen_application_array"
array_type "alert"
state "enabled"
elasticity_params do {
"bounds" => {
"max_count" => 3,
"min_count" => 2
},
"pacing" => {
"resize_calm_time" => 5,
"resize_down_by" => 1,
"resize_up_by" => 1
},
"alert_specific_params" => {
"decision_threshold" => 51,
"voters_tag_predicate" => "app_array"
}
} end
cloud_href map($clouds, $cloud, "cloud_href")
datacenter_href map($clouds, $cloud, $datacenter)
instance_type_href map($clouds, $cloud, $instance_type)
security_groups_href map($clouds, $cloud, "security_group")
ssh_key_href map($clouds, $cloud, "ssh_key")
server_template_href("/api/server_templates/336642003")
inputs do {
"repo/default/repository" => "text:https://github.com/rs-services/cookbooks_internal",
"repo/default/revision" => join(["text:",$branch])
} end
end
operation "provision" do
definition "provision"
description "Launch hosts"
end
define provision(@load_balancer,@app_array) return @load_balancer,@app_array do
@@global_load_balancer = @load_balancer
@@global_app_array = @app_array
concurrent do
provision(@@global_load_balancer)
provision(@@global_app_array)
end
@load_balancer = @@global_load_balancer
@app_array = @@global_app_array
end
output do
label "IP Address"
category "Networking"
value @load_balancer.public_ip_address
description "Load Balancer Public IP"
end