forked from svpmtrust/autotest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaws.cf
More file actions
199 lines (191 loc) · 7.52 KB
/
aws.cf
File metadata and controls
199 lines (191 loc) · 7.52 KB
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
{
"Description" : "Template to start a git server instance. Note this is not production quality template",
"Parameters" : {
"InstanceType" : {
"Description" : "What type of instance to be used. As the load increases, better disk IO will be needed",
"Type" : "String",
"AllowedValues" : [ "t1.micro",
"m1.small","m1.medium","m1.large", "m1.xlarge",
"m2.xlarge","m2.2xlarge","m2.4xlarge",
"m3.xlarge","m3.2xlarge",
"c1.medium","c1.xlarge","cc2.8xlarge",
"c3.2xlarge"
],
"Default": "c3.2xlarge",
"ConstraintDescription" : "must be a valid EC2 instance type."
},
"KeyName" : {
"Description" : "What key allows SSH access",
"Type" : "String"
},
"SSHLocation" : {
"Description" : "Which IP addresses are allowed to ssh. Note: Default is very unsecure",
"Type": "String",
"Default": "0.0.0.0/0",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "Enter a valid IP in x.x.x.x/x CIDR form ."
},
"Zone" : {
"Description" : "Which AWS zone to use",
"Type": "String",
"ConstraintDescription": "Must be a valid zone.",
"AllowedValues" : ["us-east-1d", "us-east-1a", "us-east-1c", "us-west-2a", "us-west-2b", "us-west-2c"]
},
"DBPassword" : {
"Description" : "Mongodb password",
"Type": "String",
"NoEcho" : "True"
}
},
"Mappings" : {
"InstArchMap" : {
"m1.xlarge" : { "Arch" : "64" },
"m2.xlarge" : { "Arch" : "64" },
"m2.2xlarge" : { "Arch" : "64" },
"m2.4xlarge" : { "Arch" : "64" },
"m3.xlarge" : { "Arch" : "64" },
"m3.2xlarge" : { "Arch" : "64" },
"c1.medium" : { "Arch" : "64" },
"c1.xlarge" : { "Arch" : "64" },
"c3.2xlarge" : { "Arch" : "64" },
"cc2.8xlarge" : { "Arch" : "HVM" }
},
"RegionAMIMap" : {
"us-east-1" : {
"32" : "ami-0745d26e",
"64" : "ami-0745d26e",
"HVM":"ami-0745d26e" }
}
},
"Resources" : {
"SecurityGroup": {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable SSH access to select IPs and web access to all",
"SecurityGroupIngress" : [
{
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : { "Ref" : "SSHLocation"}
},
{
"IpProtocol" : "tcp",
"FromPort" : "80",
"ToPort" : "80",
"CidrIp" : "0.0.0.0/0"
}
]
}
},
"DBAccessRule": {
"Type" : "AWS::EC2::SecurityGroupIngress",
"Properties" : {
"IpProtocol" : "tcp",
"ToPort" : "27017",
"FromPort" : "27017",
"GroupName": { "Ref": "SecurityGroup" },
"CidrIp" : "0.0.0.0/0"
}
},
"GitServer": {
"Type": "AWS::EC2::Instance",
"Properties": {
"AvailabilityZone": { "Ref": "Zone" },
"InstanceType": { "Ref": "InstanceType" },
"KeyName": { "Ref": "KeyName" },
"Tags" : [
{"Key" : "Name", "Value" : "Git Server - Tech Challenge"}
],
"Monitoring": true,
"ImageId" : { "Fn::FindInMap" : [ "RegionAMIMap", { "Ref" : "AWS::Region" },
{ "Fn::FindInMap" : [ "InstArchMap", { "Ref" : "InstanceType" },
"Arch" ] } ] },
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["\n",[
"#!/bin/bash -ex",
"sudo apt-get update",
"sudo apt-get install -y git",
"sudo apt-get install -y puppet",
"cd /tmp",
"git clone http://github.com/svpmtrust/autotest.git autotest",
"cp -r autotest/gitserver/* /etc/puppet",
"cd /etc/puppet",
"puppet apply -v -l /var/log/puppet.log gitserver.pp",
"cd /opt",
"git clone http://github.com/ratanraj/tetris.git",
"cd tetris",
"sudo cp tetris.conf /etc/init",
"echo export DB_HOST=mongodb://autotest:", { "Ref" : "DBPassword" } ,"@", { "Fn::GetAtt" : [ "DBServer", "PublicDnsName" ] } ,":27017/autotest>>env.sh\n",
"service tetris start"
]]}},
"SecurityGroups" : [ { "Ref" : "SecurityGroup" } ]
}
},
"DBServer": {
"Type": "AWS::EC2::Instance",
"Properties": {
"AvailabilityZone": { "Ref": "Zone" },
"InstanceType": { "Ref": "InstanceType" },
"KeyName": { "Ref": "KeyName" },
"Tags" : [
{"Key" : "Name", "Value" : "DB Server - Tech Challenge"}
],
"Monitoring": true,
"ImageId" : { "Fn::FindInMap" : [ "RegionAMIMap", { "Ref" : "AWS::Region" },
{ "Fn::FindInMap" : [ "InstArchMap", { "Ref" : "InstanceType" },
"Arch" ] } ] },
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["\n",[
"#!/bin/bash -ex",
"sudo apt-get update",
"sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10",
"echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list",
"sudo apt-get update",
"sudo apt-get install -y mongodb-org",
"sudo sed 's/bind_ip *= *[0-9.]*/bind_ip=0.0.0.0/w /tmp/mongod.conf' /etc/mongod.conf",
"sudo cp /tmp/mongod.conf /etc/mongod.conf",
"mongo --quiet --eval 'db.addUser(\"autotest\",\"",{"Ref":"DBPassword"},"\")' autotest",
""
]]}},
"SecurityGroups" : [ { "Ref" : "SecurityGroup" } ]
}
},
"TestServer": {
"Type": "AWS::EC2::Instance",
"Properties": {
"AvailabilityZone": { "Ref": "Zone" },
"InstanceType": { "Ref": "InstanceType" },
"KeyName": { "Ref": "KeyName" },
"Tags" : [
{"Key" : "Name", "Value" : "Test Server - Tech Challenge"}
],
"Monitoring": true,
"ImageId" : { "Fn::FindInMap" : [ "RegionAMIMap", { "Ref" : "AWS::Region" },
{ "Fn::FindInMap" : [ "InstArchMap", { "Ref" : "InstanceType" },
"Arch" ] } ] },
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["",[
"#!/bin/bash -ex\n",
"sudo apt-get update\n",
"sudo apt-get install -y git puppet mongodb python-pip\n",
"sudo pip install pymongo\n",
"cd /opt\n",
"git clone http://github.com/svpmtrust/autotest.git autotest\n",
"cd autotest\n",
"sed s/__GIT_HOST__/",{ "Fn::GetAtt" : [ "GitServer", "PublicDnsName" ]}, "/ testserver/env.sh.templ > testserver/env.sh\n",
"echo export DB_HOST=mongodb://autotest:", { "Ref" : "DBPassword" } ,"@", { "Fn::GetAtt" : [ "DBServer", "PublicDnsName" ] } ,":27017/autotest>>testserver/env.sh\n",
"mkdir mails\n",
"mkdir programs\n",
"mkdir participants\n",
"cp testserver/test-server.upstart.templ /etc/init/testserver.conf\n",
"sudo service testserver start\n"
]]}},
"SecurityGroups" : [ { "Ref" : "SecurityGroup" } ]
}
}
},
"Outputs" : {
"GitServerAddress" : {
"Description" : "Location of git server to use",
"Value" : { "Fn::Join" : [ "", [ "http://", { "Fn::GetAtt" : [ "GitServer", "PublicDnsName" ]}]]}
}
}
}