~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to templates/WordPress_Single_Instance_With_IHA.template

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Yolanda Robla, Chuck Short
  • Date: 2013-07-22 16:22:29 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130722162229-zzvfu40id94ii0hc
Tags: 2013.2~b2-0ubuntu1
[ Yolanda Robla ]
* debian/tests: added autopkg tests

[ Chuck Short ]
* New upstream release
* debian/control:
  - Add python-pbr to build-depends.
  - Add python-d2to to build-depends.
  - Dropped python-argparse.
  - Add python-six to build-depends.
  - Dropped python-sendfile.
  - Dropped python-nose.
  - Added testrepository.
  - Added python-testtools.
* debian/rules: Run testrepository instead of nosetets.
* debian/patches/removes-lxml-version-limitation-from-pip-requires.patch: Dropped
  no longer needed.
* debian/patches/fix-package-version-detection-when-building-doc.patch: Dropped
  no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{
2
 
  "AWSTemplateFormatVersion" : "2010-09-09",
3
 
 
4
 
  "Description" : "AWS CloudFormation Sample Template WordPress_Multi_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other using a local MySQL database to store the data.",
5
 
 
6
 
  "Parameters" : {
7
 
 
8
 
    "KeyName" : {
9
 
      "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
10
 
      "Type" : "String"
11
 
    },
12
 
 
13
 
    "InstanceType" : {
14
 
      "Description" : "WebServer EC2 instance type",
15
 
      "Type" : "String",
16
 
      "Default" : "m1.large",
17
 
      "AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
18
 
      "ConstraintDescription" : "must be a valid EC2 instance type."
19
 
    },
20
 
 
21
 
    "DBName": {
22
 
      "Default": "wordpress",
23
 
      "Description" : "The WordPress database name",
24
 
      "Type": "String",
25
 
      "MinLength": "1",
26
 
      "MaxLength": "64",
27
 
      "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
28
 
      "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
29
 
    },
30
 
 
31
 
    "DBUsername": {
32
 
      "Default": "admin",
33
 
      "NoEcho": "true",
34
 
      "Description" : "The WordPress database admin account username",
35
 
      "Type": "String",
36
 
      "MinLength": "1",
37
 
      "MaxLength": "16",
38
 
      "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
39
 
      "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
40
 
    },
41
 
 
42
 
    "DBPassword": {
43
 
      "Default": "admin",
44
 
      "NoEcho": "true",
45
 
      "Description" : "The WordPress database admin account password",
46
 
      "Type": "String",
47
 
      "MinLength": "1",
48
 
      "MaxLength": "41",
49
 
      "AllowedPattern" : "[a-zA-Z0-9]*",
50
 
      "ConstraintDescription" : "must contain only alphanumeric characters."
51
 
    },
52
 
 
53
 
    "DBRootPassword": {
54
 
      "Default": "admin",
55
 
      "NoEcho": "true",
56
 
      "Description" : "Root password for MySQL",
57
 
      "Type": "String",
58
 
      "MinLength": "1",
59
 
      "MaxLength": "41",
60
 
      "AllowedPattern" : "[a-zA-Z0-9]*",
61
 
      "ConstraintDescription" : "must contain only alphanumeric characters."
62
 
    },
63
 
    "LinuxDistribution": {
64
 
      "Default": "F17",
65
 
      "Description" : "Distribution of choice",
66
 
      "Type": "String",
67
 
      "AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
68
 
    },
69
 
    "HupPollInterval": {
70
 
      "Default": "1",
71
 
      "Description" : "Interval for cfn-hup",
72
 
      "Type": "String"
73
 
    }
74
 
  },
75
 
 
76
 
  "Mappings" : {
77
 
    "AWSInstanceType2Arch" : {
78
 
      "t1.micro"    : { "Arch" : "32" },
79
 
      "m1.small"    : { "Arch" : "32" },
80
 
      "m1.large"    : { "Arch" : "64" },
81
 
      "m1.xlarge"   : { "Arch" : "64" },
82
 
      "m2.xlarge"   : { "Arch" : "64" },
83
 
      "m2.2xlarge"  : { "Arch" : "64" },
84
 
      "m2.4xlarge"  : { "Arch" : "64" },
85
 
      "c1.medium"   : { "Arch" : "32" },
86
 
      "c1.xlarge"   : { "Arch" : "64" },
87
 
      "cc1.4xlarge" : { "Arch" : "64" }
88
 
    },
89
 
    "DistroArch2AMI": {
90
 
      "F18"      : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
91
 
      "F17"      : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
92
 
      "U10"      : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
93
 
      "RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
94
 
      "RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
95
 
      "RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
96
 
    }
97
 
  },
98
 
 
99
 
  "Resources" : {
100
 
    "CfnUser" : {
101
 
      "Type" : "AWS::IAM::User"
102
 
    },
103
 
    "WebServerKeys" : {
104
 
      "Type" : "AWS::IAM::AccessKey",
105
 
      "Properties" : {
106
 
        "UserName" : {"Ref": "CfnUser"}
107
 
      }
108
 
    },
109
 
    "WebServerRestartPolicy" : {
110
 
      "Type" : "OS::Heat::HARestarter",
111
 
      "Properties" : {
112
 
        "InstanceId" : { "Ref" : "WikiDatabase" }
113
 
      }
114
 
    },
115
 
    "HeartbeatFailureAlarm": {
116
 
     "Type": "AWS::CloudWatch::Alarm",
117
 
     "DependsOn" : "WaitCondition",
118
 
     "Properties": {
119
 
        "AlarmDescription": "Restart the WikiDatabase if we miss a heartbeat",
120
 
        "MetricName": "Heartbeat",
121
 
        "Namespace": "system/linux",
122
 
        "Statistic": "SampleCount",
123
 
        "Period": "60",
124
 
        "EvaluationPeriods": "1",
125
 
        "Threshold": "1",
126
 
        "AlarmActions": [ { "Ref": "WebServerRestartPolicy" } ],
127
 
        "ComparisonOperator": "LessThanThreshold"
128
 
      }
129
 
    },
130
 
    "WikiDatabase": {
131
 
      "Type": "AWS::EC2::Instance",
132
 
      "Metadata" : {
133
 
        "AWS::CloudFormation::Init" : {
134
 
          "config" : {
135
 
            "files" : {
136
 
              "/etc/cfn/cfn-credentials" : {
137
 
                "content" : { "Fn::Join" : ["", [
138
 
                  "AWSAccessKeyId=", { "Ref" : "WebServerKeys" }, "\n",
139
 
                  "AWSSecretKey=", {"Fn::GetAtt": ["WebServerKeys",
140
 
                                    "SecretAccessKey"]}, "\n"
141
 
                ]]},
142
 
                "mode"    : "000400",
143
 
                "owner"   : "root",
144
 
                "group"   : "root"
145
 
              },
146
 
              "/etc/cfn/cfn-hup.conf" : {
147
 
                "content" : { "Fn::Join" : ["", [
148
 
                  "[main]\n",
149
 
                  "stack=", { "Ref" : "AWS::StackName" }, "\n",
150
 
                  "credential-file=/etc/cfn/cfn-credentials\n",
151
 
                  "region=", { "Ref" : "AWS::Region" }, "\n",
152
 
                  "interval=", { "Ref" : "HupPollInterval" }, "\n"
153
 
                ]]},
154
 
                "mode"    : "000400",
155
 
                "owner"   : "root",
156
 
                "group"   : "root"
157
 
              },
158
 
              "/tmp/cfn-hup-crontab.txt" : {
159
 
                "content" : { "Fn::Join" : ["", [
160
 
                "MAIL=\"\"\n",
161
 
                "\n",
162
 
                "* * * * * /opt/aws/bin/cfn-hup -f\n",
163
 
                "* * * * * /opt/aws/bin/cfn-push-stats ",
164
 
                " --watch ", { "Ref" : "HeartbeatFailureAlarm" },
165
 
                " --heartbeat\n"
166
 
                ]]},
167
 
                "mode"    : "000600",
168
 
                "owner"   : "root",
169
 
                "group"   : "root"
170
 
              },
171
 
 
172
 
              "/tmp/setup.mysql" : {
173
 
                "content" : { "Fn::Join" : ["", [
174
 
                "CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
175
 
                "GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" },
176
 
                ".* TO '", { "Ref" : "DBUsername" }, "'@'localhost'\n",
177
 
                "IDENTIFIED BY '", { "Ref" : "DBPassword" }, "';\n",
178
 
                "FLUSH PRIVILEGES;\n",
179
 
                "EXIT\n"
180
 
                  ]]},
181
 
                "mode"  : "000644",
182
 
                "owner" : "root",
183
 
                "group" : "root"
184
 
              }
185
 
            },
186
 
            "packages" : {
187
 
              "yum" : {
188
 
                "cronie"       : [],
189
 
                "mysql"        : [],
190
 
                "mysql-server" : [],
191
 
                "httpd"        : [],
192
 
                "wordpress"    : []
193
 
              }
194
 
            },
195
 
            "services" : {
196
 
              "systemd" : {
197
 
                "mysqld"   : { "enabled" : "true", "ensureRunning" : "true" },
198
 
                "httpd"    : { "enabled" : "true", "ensureRunning" : "true" },
199
 
                "crond"    : { "enabled" : "true", "ensureRunning" : "true" }
200
 
              }
201
 
            }
202
 
          }
203
 
        }
204
 
      },
205
 
      "Properties": {
206
 
        "ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
207
 
                          { "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
208
 
        "InstanceType"   : { "Ref" : "InstanceType" },
209
 
        "KeyName"        : { "Ref" : "KeyName" },
210
 
        "UserData"       : { "Fn::Base64" : { "Fn::Join" : ["", [
211
 
          "#!/bin/bash -v\n",
212
 
          "# Helper function\n",
213
 
          "function error_exit\n",
214
 
          "{\n",
215
 
          "  /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "WaitHandle" }, "'\n",
216
 
          "  exit 1\n",
217
 
          "}\n",
218
 
 
219
 
          "/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
220
 
          " -r WikiDatabase ",
221
 
          " --region ", { "Ref" : "AWS::Region" },
222
 
          " || error_exit 'Failed to run cfn-init'\n",
223
 
 
224
 
          "# Setup MySQL root password and create a user\n",
225
 
          "mysqladmin -u root password '", { "Ref" : "DBRootPassword" },
226
 
          "' || error_exit 'Failed to initialize root password'\n",
227
 
 
228
 
          "mysql -u root --password='", { "Ref" : "DBRootPassword" },
229
 
          "' < /tmp/setup.mysql || error_exit 'Failed to create database.'\n",
230
 
 
231
 
          "sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
232
 
          "sed --in-place --e s/database_name_here/", { "Ref" : "DBName" },
233
 
          "/ --e s/username_here/", { "Ref" : "DBUsername" },
234
 
          "/ --e s/password_here/", { "Ref" : "DBPassword" },
235
 
          "/ /usr/share/wordpress/wp-config.php\n",
236
 
 
237
 
          "systemctl restart httpd.service\n",
238
 
 
239
 
          "# install cfn-hup crontab\n",
240
 
          "crontab /tmp/cfn-hup-crontab.txt\n",
241
 
 
242
 
          "# All is well so signal success\n",
243
 
          "/opt/aws/bin/cfn-signal -e 0 -r \"Wiki server setup complete\" '",
244
 
          { "Ref" : "WaitHandle" }, "'\n"
245
 
        ]]}}
246
 
      }
247
 
    },
248
 
 
249
 
    "WaitHandle" : {
250
 
      "Type" : "AWS::CloudFormation::WaitConditionHandle"
251
 
    },
252
 
 
253
 
    "WaitCondition" : {
254
 
      "Type" : "AWS::CloudFormation::WaitCondition",
255
 
      "DependsOn" : "WikiDatabase",
256
 
      "Properties" : {
257
 
        "Handle" : {"Ref" : "WaitHandle"},
258
 
        "Timeout" : "600"
259
 
      }
260
 
    }
261
 
  },
262
 
 
263
 
  "Outputs" : {
264
 
    "WebsiteURL" : {
265
 
      "Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/wordpress"]] },
266
 
      "Description" : "URL for Wordpress wiki"
267
 
    }
268
 
  }
269
 
}