Initial import of content which currently exists in the main heat repo Change-Id: I326801f7e7274a1f8b41d4e0be733da0f80ebbccchanges/27/27627/1
parent
d94bf0c3d8
commit
de67cecf92
@ -0,0 +1,176 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
@ -0,0 +1,11 @@
|
||||
==============
|
||||
Heat Templates
|
||||
==============
|
||||
|
||||
Heat is a service to orchestrate multiple composite cloud applications using
|
||||
templates
|
||||
|
||||
This repository provides:
|
||||
* Example templates which demonstrate core Heat functionality
|
||||
* Related image-building templates
|
||||
* Template-related scripts and conversion tools
|
@ -0,0 +1,296 @@
|
||||
{
|
||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
||||
|
||||
"Description" : "AWS CloudFormation Sample Template",
|
||||
|
||||
"Parameters" : {
|
||||
|
||||
"KeyName" : {
|
||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
||||
"Type" : "String"
|
||||
},
|
||||
|
||||
"InstanceType" : {
|
||||
"Description" : "WebServer EC2 instance type",
|
||||
"Type" : "String",
|
||||
"Default" : "m1.small",
|
||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
||||
},
|
||||
|
||||
"DBName": {
|
||||
"Default": "wordpress",
|
||||
"Description" : "The WordPress database name",
|
||||
"Type": "String",
|
||||
"MinLength": "1",
|
||||
"MaxLength": "64",
|
||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
||||
},
|
||||
|
||||
"DBUsername": {
|
||||
"Default": "admin",
|
||||
"NoEcho": "true",
|
||||
"Description" : "The WordPress database admin account username",
|
||||
"Type": "String",
|
||||
"MinLength": "1",
|
||||
"MaxLength": "16",
|
||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
||||
},
|
||||
|
||||
"DBPassword": {
|
||||
"Default": "admin",
|
||||
"NoEcho": "true",
|
||||
"Description" : "The WordPress database admin account password",
|
||||
"Type": "String",
|
||||
"MinLength": "1",
|
||||
"MaxLength": "41",
|
||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
||||
},
|
||||
|
||||
"DBRootPassword": {
|
||||
"Default": "admin",
|
||||
"NoEcho": "true",
|
||||
"Description" : "Root password for MySQL",
|
||||
"Type": "String",
|
||||
"MinLength": "1",
|
||||
"MaxLength": "41",
|
||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
||||
},
|
||||
|
||||
"LinuxDistribution": {
|
||||
"Default": "F17",
|
||||
"Description" : "Distribution of choice",
|
||||
"Type": "String",
|
||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
||||
}
|
||||
},
|
||||
|
||||
"Mappings" : {
|
||||
"AWSInstanceType2Arch" : {
|
||||
"t1.micro" : { "Arch" : "32" },
|
||||
"m1.small" : { "Arch" : "64" },
|
||||
"m1.large" : { "Arch" : "64" },
|
||||
"m1.xlarge" : { "Arch" : "64" },
|
||||
"m2.xlarge" : { "Arch" : "64" },
|
||||
"m2.2xlarge" : { "Arch" : "64" },
|
||||
"m2.4xlarge" : { "Arch" : "64" },
|
||||
"c1.medium" : { "Arch" : "32" },
|
||||
"c1.xlarge" : { "Arch" : "64" },
|
||||
"cc1.4xlarge" : { "Arch" : "64" }
|
||||
},
|
||||
"DistroArch2AMI": {
|
||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
||||
}
|
||||
},
|
||||
|
||||
"Resources" : {
|
||||
"CfnUser" : {
|
||||
"Type" : "AWS::IAM::User"
|
||||
},
|
||||
"WebServerKeys" : {
|
||||
"Type" : "AWS::IAM::AccessKey",
|
||||
"Properties" : {
|
||||
"UserName" : {"Ref": "CfnUser"}
|
||||
}
|
||||
},
|
||||
"WebServerGroup" : {
|
||||
"Type" : "AWS::AutoScaling::AutoScalingGroup",
|
||||
"Properties" : {
|
||||
"AvailabilityZones" : { "Fn::GetAZs" : ""},
|
||||
"LaunchConfigurationName" : { "Ref" : "LaunchConfig" },
|
||||
"MinSize" : "1",
|
||||
"MaxSize" : "3",
|
||||
"LoadBalancerNames" : [ { "Ref" : "ElasticLoadBalancer" } ]
|
||||
}
|
||||
},
|
||||
|
||||
"WebServerScaleUpPolicy" : {
|
||||
"Type" : "AWS::AutoScaling::ScalingPolicy",
|
||||
"Properties" : {
|
||||
"AdjustmentType" : "ChangeInCapacity",
|
||||
"AutoScalingGroupName" : { "Ref" : "WebServerGroup" },
|
||||
"Cooldown" : "60",
|
||||
"ScalingAdjustment" : "1"
|
||||
}
|
||||
},
|
||||
|
||||
"WebServerScaleDownPolicy" : {
|
||||
"Type" : "AWS::AutoScaling::ScalingPolicy",
|
||||
"Properties" : {
|
||||
"AdjustmentType" : "ChangeInCapacity",
|
||||
"AutoScalingGroupName" : { "Ref" : "WebServerGroup" },
|
||||
"Cooldown" : "60",
|
||||
"ScalingAdjustment" : "-1"
|
||||
}
|
||||
},
|
||||
|
||||
"MEMAlarmHigh": {
|
||||
"Type": "AWS::CloudWatch::Alarm",
|
||||
"Properties": {
|
||||
"AlarmDescription": "Scale-up if MEM > 50% for 1 minute",
|
||||
"MetricName": "MemoryUtilization",
|
||||
"Namespace": "system/linux",
|
||||
"Statistic": "Average",
|
||||
"Period": "60",
|
||||
"EvaluationPeriods": "1",
|
||||
"Threshold": "50",
|
||||
"AlarmActions": [ { "Ref": "WebServerScaleUpPolicy" } ],
|
||||
"Dimensions": [
|
||||
{
|
||||
"Name": "AutoScalingGroupName",
|
||||
"Value": { "Ref": "WebServerGroup" }
|
||||
}
|
||||
],
|
||||
"ComparisonOperator": "GreaterThanThreshold"
|
||||
}
|
||||
},
|
||||
"MEMAlarmLow": {
|
||||
"Type": "AWS::CloudWatch::Alarm",
|
||||
"Properties": {
|
||||
"AlarmDescription": "Scale-down if MEM < 15% for 1 minute",
|
||||
"MetricName": "MemoryUtilization",
|
||||
"Namespace": "system/linux",
|
||||
"Statistic": "Average",
|
||||
"Period": "60",
|
||||
"EvaluationPeriods": "1",
|
||||
"Threshold": "15",
|
||||
"AlarmActions": [ { "Ref": "WebServerScaleDownPolicy" } ],
|
||||
"Dimensions": [
|
||||
{
|
||||
"Name": "AutoScalingGroupName",
|
||||
"Value": { "Ref": "WebServerGroup" }
|
||||
}
|
||||
],
|
||||
"ComparisonOperator": "LessThanThreshold"
|
||||
}
|
||||
},
|
||||
|
||||
"ElasticLoadBalancer" : {
|
||||
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
|
||||
"Properties" : {
|
||||
"AvailabilityZones" : { "Fn::GetAZs" : "" },
|
||||
"Listeners" : [ {
|
||||
"LoadBalancerPort" : "80",
|
||||
"InstancePort" : "80",
|
||||
"Protocol" : "HTTP"
|
||||
} ],
|
||||
"HealthCheck" : {
|
||||
"Target" : "HTTP:80/",
|
||||
"HealthyThreshold" : "3",
|
||||
"UnhealthyThreshold" : "5",
|
||||
"Interval" : "30",
|
||||
"Timeout" : "5"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"LaunchConfig" : {
|
||||
"Type" : "AWS::AutoScaling::LaunchConfiguration",
|
||||
"Metadata" : {
|
||||
"AWS::CloudFormation::Init" : {
|
||||
"config" : {
|
||||
"files" : {
|
||||
"/etc/cfn/cfn-credentials" : {
|
||||
"content" : { "Fn::Join" : ["", [
|
||||
"AWSAccessKeyId=", { "Ref" : "WebServerKeys" }, "\n",
|
||||
"AWSSecretKey=", {"Fn::GetAtt": ["WebServerKeys",
|
||||
"SecretAccessKey"]}, "\n"
|
||||
]]},
|
||||
"mode" : "000400",
|
||||
"owner" : "root",
|
||||
"group" : "root"
|
||||
},
|
||||
"/tmp/setup.mysql" : {
|
||||
"content" : { "Fn::Join" : ["", [
|
||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" },
|
||||
".* TO '", { "Ref" : "DBUsername" }, "'@'localhost'\n",
|
||||
"IDENTIFIED BY '", { "Ref" : "DBPassword" }, "';\n",
|
||||
"FLUSH PRIVILEGES;\n",
|
||||
"EXIT\n"
|
||||
]]},
|
||||
"mode" : "000644",
|
||||
"owner" : "root",
|
||||
"group" : "root"
|
||||
},
|
||||
"/tmp/stats-crontab.txt" : {
|
||||
"content" : { "Fn::Join" : ["", [
|
||||
"MAIL=\"\"\n",
|
||||
"\n",
|
||||
"* * * * * /opt/aws/bin/cfn-push-stats --watch ",
|
||||
{ "Ref" : "MEMAlarmHigh" }, " --mem-util\n",
|
||||
"* * * * * /opt/aws/bin/cfn-push-stats --watch ",
|
||||
{ "Ref" : "MEMAlarmLow" }, " --mem-util\n"
|
||||
]]},
|
||||
"mode" : "000600",
|
||||
"owner" : "root",
|
||||
"group" : "root"
|
||||
}
|
||||
},
|
||||
"packages" : {
|
||||
"yum" : {
|
||||
"python-psutil": [],
|
||||
"cronie" : [],
|
||||
"mysql" : [],
|
||||
"mysql-server" : [],
|
||||
"httpd" : [],
|
||||
"wordpress" : []
|
||||
}
|
||||
},
|
||||
"services" : {
|
||||
"systemd" : {
|
||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
|
||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
||||
"crond" : { "enabled" : "true", "ensureRunning" : "true" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Properties": {
|
||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
||||
"InstanceType" : { "Ref" : "InstanceType" },
|
||||
"KeyName" : { "Ref" : "KeyName" },
|
||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
||||
"#!/bin/bash -v\n",
|
||||
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
|
||||
" -r LaunchConfig ",
|
||||
" --region ", { "Ref" : "AWS::Region" }, "\n",
|
||||
|
||||
"# Setup MySQL root password and create a user\n",
|
||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
||||
|
||||
"mysql -u root --password='", { "Ref" : "DBRootPassword" },
|
||||
"' < /tmp/setup.mysql\n",
|
||||
|
||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" },
|
||||
"/ --e s/username_here/", { "Ref" : "DBUsername" },
|
||||
"/ --e s/password_here/", { "Ref" : "DBPassword" },
|
||||
"/ /usr/share/wordpress/wp-config.php\n",
|
||||
"systemctl restart httpd.service\n",
|
||||
|
||||
"# install crontab\n",
|
||||
"crontab /tmp/stats-crontab.txt\n"
|
||||
]]}}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"Outputs" : {
|
||||
"URL" : {
|
||||
"Description" : "The URL of the website",
|
||||
"Value" : { "Fn::Join" : [ "", [ "http://", { "Fn::GetAtt" : [ "ElasticLoadBalancer", "DNSName" ]}, "/wordpress"]] }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,283 @@
|
||||
HeatTemplateFormatVersion: '2012-12-12'
|
||||
Description: AWS CloudFormation Sample Template
|
||||
Parameters:
|
||||
KeyName: {Description: Name of an existing EC2 KeyPair
|
||||
to enable SSH access to the instances, Type: String}
|
||||
InstanceType:
|
||||
Description: WebServer EC2 instance type
|
||||
Type: String
|
||||
Default: m1.small
|
||||
AllowedValues: [t1.micro, m1.small, m1.large, m1.xlarge, m2.xlarge,
|
||||
m2.2xlarge, m2.4xlarge, c1.medium, c1.xlarge, cc1.4xlarge]
|
||||
ConstraintDescription: must be a valid EC2 instance type.
|
||||
DBName: {Default: wordpress, Description: The
|
||||
WordPress database name, Type: String, MinLength: '1',
|
||||
MaxLength: '64', AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*',
|
||||
ConstraintDescription: must begin with a letter and contain only
|
||||
alphanumeric characters.}
|
||||
DBUsername: {Default: admin, NoEcho: 'true',
|
||||
Description: The WordPress database admin account username, Type: String,
|
||||
MinLength: '1', MaxLength: '16', AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*',
|
||||
ConstraintDescription: must begin with a letter and contain only
|
||||
alphanumeric characters.}
|
||||
DBPassword: {Default: admin, NoEcho: 'true',
|
||||
Description: The WordPress database admin account password, Type: String,
|
||||
MinLength: '1', MaxLength: '41', AllowedPattern: '[a-zA-Z0-9]*',
|
||||
ConstraintDescription: must contain only alphanumeric characters.}
|
||||
DBRootPassword: {Default: admin, NoEcho: 'true',
|
||||
Description: Root password for MySQL, Type: String,
|
||||
MinLength: '1', MaxLength: '41', AllowedPattern: '[a-zA-Z0-9]*',
|
||||
ConstraintDescription: must contain only alphanumeric characters.}
|
||||
LinuxDistribution:
|
||||
Default: F17
|
||||
Description: Distribution of choice
|
||||
Type: String
|
||||
AllowedValues: [F18, F17, U10, RHEL-6.1, RHEL-6.2, RHEL-6.3]
|
||||
Mappings:
|
||||
AWSInstanceType2Arch:
|
||||
t1.micro: {Arch: '32'}
|
||||
m1.small: {Arch: '64'}
|
||||
m1.large: {Arch: '64'}
|
||||
m1.xlarge: {Arch: '64'}
|
||||
m2.xlarge: {Arch: '64'}
|
||||
m2.2xlarge: {Arch: '64'}
|
||||
m2.4xlarge: {Arch: '64'}
|
||||
c1.medium: {Arch: '32'}
|
||||
c1.xlarge: {Arch: '64'}
|
||||
cc1.4xlarge: {Arch: '64'}
|
||||
DistroArch2AMI:
|
||||
F18: {'32': F18-i386-cfntools, '64': F18-x86_64-cfntools}
|
||||
F17: {'32': F17-i386-cfntools, '64': F17-x86_64-cfntools}
|
||||
U10: {'32': U10-i386-cfntools, '64': U10-x86_64-cfntools}
|
||||
RHEL-6.1: {'32': rhel61-i386-cfntools, '64': rhel61-x86_64-cfntools}
|
||||
RHEL-6.2: {'32': rhel62-i386-cfntools, '64': rhel62-x86_64-cfntools}
|
||||
RHEL-6.3: {'32': rhel63-i386-cfntools, '64': rhel63-x86_64-cfntools}
|
||||
Resources:
|
||||
CfnUser: {Type: 'AWS::IAM::User'}
|
||||
WebServerKeys:
|
||||
Type: AWS::IAM::AccessKey
|
||||
Properties:
|
||||
UserName: {Ref: CfnUser}
|
||||
WebServerGroup:
|
||||
Type: AWS::AutoScaling::AutoScalingGroup
|
||||
Properties:
|
||||
AvailabilityZones: {'Fn::GetAZs': ''}
|
||||
LaunchConfigurationName: {Ref: LaunchConfig}
|
||||
MinSize: '1'
|
||||
MaxSize: '3'
|
||||
LoadBalancerNames:
|
||||
- {Ref: ElasticLoadBalancer}
|
||||
WebServerScaleUpPolicy:
|
||||
Type: AWS::AutoScaling::ScalingPolicy
|
||||
Properties:
|
||||
AdjustmentType: ChangeInCapacity
|
||||
AutoScalingGroupName: {Ref: WebServerGroup}
|
||||
Cooldown: '60'
|
||||
ScalingAdjustment: '1'
|
||||
WebServerScaleDownPolicy:
|
||||
Type: AWS::AutoScaling::ScalingPolicy
|
||||
Properties:
|
||||
AdjustmentType: ChangeInCapacity
|
||||
AutoScalingGroupName: {Ref: WebServerGroup}
|
||||
Cooldown: '60'
|
||||
ScalingAdjustment: '-1'
|
||||
MEMAlarmHigh:
|
||||
Type: AWS::CloudWatch::Alarm
|
||||
Properties:
|
||||
AlarmDescription: Scale-up if MEM > 50% for 1 minute
|
||||
MetricName: MemoryUtilization
|
||||
Namespace: system/linux
|
||||
Statistic: Average
|
||||
Period: '60'
|
||||
EvaluationPeriods: '1'
|
||||
Threshold: '50'
|
||||
AlarmActions:
|
||||
- {Ref: WebServerScaleUpPolicy}
|
||||
Dimensions:
|
||||
- Name: AutoScalingGroupName
|
||||
Value: {Ref: WebServerGroup}
|
||||
ComparisonOperator: GreaterThanThreshold
|
||||
MEMAlarmLow:
|
||||
Type: AWS::CloudWatch::Alarm
|
||||
Properties:
|
||||
AlarmDescription: Scale-down if MEM < 15% for 1 minute
|
||||
MetricName: MemoryUtilization
|
||||
Namespace: system/linux
|
||||
Statistic: Average
|
||||
Period: '60'
|
||||
EvaluationPeriods: '1'
|
||||
Threshold: '15'
|
||||
AlarmActions:
|
||||
- {Ref: WebServerScaleDownPolicy}
|
||||
Dimensions:
|
||||
- Name: AutoScalingGroupName
|
||||
Value: {Ref: WebServerGroup}
|
||||
ComparisonOperator: LessThanThreshold
|
||||
ElasticLoadBalancer:
|
||||
Type: AWS::ElasticLoadBalancing::LoadBalancer
|
||||
Properties:
|
||||
AvailabilityZones: {'Fn::GetAZs': ''}
|
||||
Listeners:
|
||||
- {LoadBalancerPort: '80', InstancePort: '80',
|
||||
Protocol: HTTP}
|
||||
HealthCheck: {Target: 'HTTP:80/', HealthyThreshold: '3',
|
||||
UnhealthyThreshold: '5', Interval: '30', Timeout: '5'}
|
||||
LaunchConfig:
|
||||
Type: AWS::AutoScaling::LaunchConfiguration
|
||||
Metadata:
|
||||
AWS::CloudFormation::Init:
|
||||
config:
|
||||
files:
|
||||
/etc/cfn/cfn-credentials:
|
||||
content:
|
||||
Fn::Join:
|
||||
- ''
|
||||
- - AWSAccessKeyId=
|
||||
- {Ref: WebServerKeys}
|
||||
- '
|
||||
|
||||
'
|
||||
- AWSSecretKey=
|
||||
- Fn::GetAtt: [WebServerKeys, SecretAccessKey]
|
||||
- '
|
||||
|
||||
'
|
||||
mode: '000400'
|
||||
owner: root
|
||||
group: root
|
||||
/tmp/setup.mysql:
|
||||
content:
|
||||
Fn::Join:
|
||||
- ''
|
||||
- - 'CREATE DATABASE '
|
||||
- {Ref: DBName}
|
||||
- ';
|
||||
|
||||
'
|
||||
- 'GRANT ALL PRIVILEGES ON '
|
||||
- {Ref: DBName}
|
||||
- .* TO '
|
||||
- {Ref: DBUsername}
|
||||
- '''@''localhost''
|
||||
|
||||
'
|
||||
- IDENTIFIED BY '
|
||||
- {Ref: DBPassword}
|
||||
- ''';
|
||||
|
||||
'
|
||||
- 'FLUSH PRIVILEGES;
|
||||
|
||||
'
|
||||
- 'EXIT
|
||||
|
||||
'
|
||||
mode: '000644'
|
||||
owner: root
|
||||
group: root
|
||||
/tmp/stats-crontab.txt:
|
||||
content:
|
||||
Fn::Join:
|
||||
- ''
|
||||
- - 'MAIL=""
|
||||
|
||||
'
|
||||
- '
|
||||
|
||||
'
|
||||
- '* * * * * /opt/aws/bin/cfn-push-stats --watch '
|
||||
- {Ref: MEMAlarmHigh}
|
||||
- ' --mem-util
|
||||
|
||||
'
|
||||
- '* * * * * /opt/aws/bin/cfn-push-stats --watch '
|
||||
- {Ref: MEMAlarmLow}
|
||||
- ' --mem-util
|
||||
|
||||
'
|
||||
mode: '000600'
|
||||
owner: root
|
||||
group: root
|
||||
packages:
|
||||
yum:
|
||||
python-psutil: []
|
||||
cronie: []
|
||||
mysql: []
|
||||
mysql-server: []
|
||||
httpd: []
|
||||
wordpress: []
|
||||
services:
|
||||
systemd:
|
||||
mysqld: {enabled: 'true', ensureRunning: 'true'}
|
||||
httpd: {enabled: 'true', ensureRunning: 'true'}
|
||||
crond: {enabled: 'true', ensureRunning: 'true'}
|
||||
Properties:
|
||||
ImageId:
|
||||
Fn::FindInMap:
|
||||
- DistroArch2AMI
|
||||
- {Ref: LinuxDistribution}
|
||||
- Fn::FindInMap:
|
||||
- AWSInstanceType2Arch
|
||||
- {Ref: InstanceType}
|
||||
- Arch
|
||||
InstanceType: {Ref: InstanceType}
|
||||
KeyName: {Ref: KeyName}
|
||||
UserData:
|
||||
Fn::Base64:
|
||||
Fn::Join:
|
||||
- ''
|
||||
- - '#!/bin/bash -v
|
||||
|
||||
'
|
||||
- '/opt/aws/bin/cfn-init -s '
|
||||
- {Ref: 'AWS::StackName'}
|
||||
- ' -r LaunchConfig '
|
||||
- ' --region '
|
||||
- {Ref: 'AWS::Region'}
|
||||
- '
|
||||
|
||||
'
|
||||
- '# Setup MySQL root password and create a user
|
||||
|
||||
'
|
||||
- mysqladmin -u root password '
|
||||
- {Ref: DBRootPassword}
|
||||
- '''
|
||||
|
||||
'
|
||||
- mysql -u root --password='
|
||||
- {Ref: DBRootPassword}
|
||||
- ''' < /tmp/setup.mysql
|
||||
|
||||
'
|
||||
- 'sed -i "/Deny from All/d" /etc/httpd/conf.d/wordpress.conf
|
||||
|
||||
'
|
||||
- sed --in-place --e s/database_name_here/
|
||||
- {Ref: DBName}
|
||||
- / --e s/username_here/
|
||||
- {Ref: DBUsername}
|
||||
- / --e s/password_here/
|
||||
- {Ref: DBPassword}
|
||||
- '/ /usr/share/wordpress/wp-config.php
|
||||
|
||||
'
|
||||
- 'systemctl restart httpd.service
|
||||
|
||||
'
|
||||
- '# install crontab
|
||||
|
||||
'
|
||||
- 'crontab /tmp/stats-crontab.txt
|
||||
|
||||
'
|
||||
Outputs:
|
||||
URL:
|
||||
Description: The URL of the website
|
||||
Value:
|
||||
Fn::Join:
|
||||
- ''
|
||||
- - http://
|
||||
- Fn::GetAtt: [ElasticLoadBalancer, DNSName]
|
||||
- /wordpress
|
||||
|
@ -0,0 +1,114 @@
|
||||
{
|
||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
||||
|
||||
"Description" : "This template creates an instance and an EBS Volume.",
|
||||
|
||||
"Parameters" : {
|
||||
|
||||
"KeyName" : {
|
||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
||||
"Type" : "String"
|
||||
},
|
||||
|
||||
"InstanceType" : {
|
||||
"Description" : "WebServer EC2 instance type",
|
||||
"Type" : "String",
|
||||
"Default" : "m1.large",
|
||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
||||
},
|
||||
|
||||
"VolumeSize" : {
|
||||
"Description" : "WikiDatabase Volume size",
|
||||
"Type" : "Number",
|
||||
"Default" : "1",
|
||||
"MinValue" : "1",
|
||||
"MaxValue" : "1024",
|
||||
"ConstraintDescription" : "must be between 1 and 1024 Gb."
|
||||
},
|
||||
|
||||
"LinuxDistribution": {
|
||||
"Default": "F17",
|
||||
"Description" : "Distribution of choice",
|
||||
"Type": "String",
|
||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
||||
}
|
||||
},
|
||||
|
||||
"Mappings" : {
|
||||
"AWSInstanceType2Arch" : {
|
||||
"t1.micro" : { "Arch" : "32" },
|
||||
"m1.small" : { "Arch" : "32" },
|
||||
"m1.large" : { "Arch" : "64" },
|
||||
"m1.xlarge" : { "Arch" : "64" },
|
||||
"m2.xlarge" : { "Arch" : "64" },
|
||||
"m2.2xlarge" : { "Arch" : "64" },
|
||||
"m2.4xlarge" : { "Arch" : "64" },
|
||||
"c1.medium" : { "Arch" : "32" },
|
||||
"c1.xlarge" : { "Arch" : "64" },
|
||||
"cc1.4xlarge" : { "Arch" : "64" }
|
||||
},
|
||||
"DistroArch2AMI": {
|
||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
||||
}
|
||||
},
|
||||
|
||||
"Resources" : {
|
||||
"Ec2Instance" : {
|
||||
"Type" : "AWS::EC2::Instance",
|
||||
"Properties" : {
|
||||
"SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
|
||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
||||
"InstanceType" : { "Ref" : "InstanceType" },
|
||||
"KeyName" : { "Ref" : "KeyName" },
|
||||
"Volumes" : [
|
||||
{ "VolumeId" : { "Ref" : "NewVolume" },
|
||||
"Device" : "/dev/vdc1"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"InstanceSecurityGroup" : {
|
||||
"Type" : "AWS::EC2::SecurityGroup",
|
||||
"Properties" : {
|
||||
"GroupDescription" : "Enable SSH access via port 22",
|
||||
"SecurityGroupIngress" : [ {
|
||||
"IpProtocol" : "tcp",
|
||||
"FromPort" : "22",
|
||||
"ToPort" : "22",
|
||||
"CidrIp" : "0.0.0.0/0"
|
||||
}]
|
||||
}
|
||||
},
|
||||
|
||||
"NewVolume" : {
|
||||
"Type" : "AWS::EC2::Volume",
|
||||
"Properties" : {
|
||||
"Size" : { "Ref" : "VolumeSize" },
|
||||
"AvailabilityZone" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ]}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"Outputs" : {
|
||||
"InstanceId" : {
|
||||
"Description" : "InstanceId of the newly created EC2 instance",
|
||||
"Value" : { "Ref" : "Ec2Instance" }
|
||||
},
|
||||
"PublicIP" : {
|
||||
"Description" : "Public IP address of the newly created EC2 instance",
|
||||
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "PublicIp" ] }
|
||||
},
|
||||
"PublicDNS" : {
|
||||
"Description" : "Public DNSName of the newly created EC2 instance",
|
||||
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "PublicDnsName" ] }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
{
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
|
||||
"Description": "A load balancer instance running a local HAproxy",
|
||||
|
||||
"Parameters": {
|
||||
|
||||
"KeyName": {
|
||||
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
||||
"Type": "String"
|
||||
},
|
||||
|
||||
"Server1": {
|
||||
"Description": "Server1 to load balance <ip:port>",
|
||||
"Type": "String"
|
||||
},
|
||||
|
||||
"InstanceType": {
|
||||
"Description": "HAProxy server EC2 instance type",
|
||||
"Default": "m1.small",
|
||||
"Type": "String",
|
||||
"AllowedValues": [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
||||
"ConstraintDescription": "must be a valid EC2 instance type."
|
||||
},
|
||||
|
||||
"LinuxDistribution": {
|
||||
"Default": "F17",
|
||||
"Description" : "Distribution of choice",
|
||||
"Type": "String",
|
||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
||||
}
|
||||
},
|
||||
|
||||
"Mappings" : {
|
||||
"AWSInstanceType2Arch" : {
|
||||
"t1.micro" : { "Arch" : "32" },
|
||||
"m1.small" : { "Arch" : "32" },
|
||||
"m1.large" : { "Arch" : "64" },
|
||||
"m1.xlarge" : { "Arch" : "64" },
|
||||
"m2.xlarge" : { "Arch" : "64" },
|
||||
"m2.2xlarge" : { "Arch" : "64" },
|
||||
"m2.4xlarge" : { "Arch" : "64" },
|
||||
"c1.medium" : { "Arch" : "32" },
|
||||
"c1.xlarge" : { "Arch" : "64" },
|
||||
"cc1.4xlarge" : { "Arch" : "64" }
|
||||
},
|
||||
"DistroArch2AMI": {
|
||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
||||
}
|
||||
},
|
||||
|
||||
"Resources": {
|
||||
"LoadBalancerInstance": {
|
||||
"Type": "AWS::EC2::Instance",
|
||||
"Metadata": {
|
||||
"AWS::CloudFormation::Init": {
|
||||
"config": {
|
||||
"packages": {
|
||||
"yum": {
|
||||
"haproxy" : []
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"systemd": {
|
||||
"haproxy" : { "enabled": "true", "ensureRunning": "true" }
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"/etc/haproxy/haproxy.cfg": {
|
||||
"content": { "Fn::Join": ["", [
|
||||
" global\n",
|
||||
" daemon\n",
|
||||
" maxconn 256\n",
|
||||
"\n",
|
||||
" defaults\n",
|
||||
" mode http\n",
|
||||
" timeout connect 5000ms\n",
|
||||
" timeout client 50000ms\n",
|
||||
" timeout server 50000ms\n",
|
||||
"\n",
|
||||
" frontend http-in\n",
|
||||
" bind *:80\n",
|
||||
" default_backend servers\n",
|
||||
"\n",
|
||||
" backend servers\n",
|
||||
" balance roundrobin\n",
|
||||
" option http-server-close\n",
|
||||
" option forwardfor\n",
|
||||
" server server1 ", { "Ref" : "Server1" }, "\n"
|
||||
]]},
|
||||
"mode": "000644",
|
||||
"owner": "root",
|
||||
"group": "root"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Properties": {
|
||||
"ImageId" : {
|
||||
"Fn::FindInMap" : [ "DistroArch2AMI",
|
||||
{ "Ref" : "LinuxDistribution" },
|
||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch",
|
||||
{ "Ref" : "InstanceType" },
|
||||
"Arch" ] } ]
|
||||
},
|
||||
"InstanceType": { "Ref": "InstanceType" },
|
||||
"KeyName": { "Ref": "KeyName" },
|
||||
"UserData": { "Fn::Base64": { "Fn::Join": ["", [
|
||||
"#!/bin/bash -v\n",
|
||||
"/opt/aws/bin/cfn-init -s ",
|
||||
{ "Ref": "AWS::StackName" },
|
||||
" --region ", { "Ref": "AWS::Region" }, "\n"
|
||||
]]}}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"Outputs": {
|
||||
"PublicIp": {
|
||||
"Value": { "Fn::GetAtt": [ "LoadBalancerInstance", "PublicIp" ] },
|
||||
"Description": "instance IP"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
{
|
||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
||||
|
||||
"Description" : "Template to create multiple instances.",
|
||||
|
||||
"Parameters" : {
|
||||
"KeyName" : {
|
||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
||||
"Type" : "String"
|
||||
},
|
||||
"InstanceType" : {
|
||||
"Description" : "Instance type",
|
||||
"Type" : "String",
|
||||
"Default" : "m1.small",
|
||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
||||
},
|
||||
"ImageId" : {
|
||||
"Description" : "Name of the image to use",
|
||||
"Type" : "String",
|
||||
"Default" : "F17-x86_64-cfntools"
|
||||
},
|
||||
"NumInstances": {
|
||||
"Default": "1",
|
||||
"MinValue": "1",
|
||||
"MaxValue": "100",
|
||||
"Description" : "Number of instances to create",
|
||||
"Type": "Number"
|
||||
}
|
||||
},
|
||||
|
||||
"Resources" : {
|
||||
"JobServerGroup" : {
|
||||
"Type" : "OS::Heat::InstanceGroup",
|
||||
"Properties" : {
|
||||
"LaunchConfigurationName" : { "Ref" : "JobServerConfig" },
|
||||
"Size" : {"Ref": "NumInstances"},
|
||||
"AvailabilityZones" : { "Fn::GetAZs" : "" }
|
||||
}
|
||||
},
|
||||
|
||||
"JobServerConfig" : {
|
||||
"Type" : "AWS::AutoScaling::LaunchConfiguration",
|
||||
"Properties": {
|
||||
"ImageId" : { "Ref" : "ImageId" },
|
||||
"InstanceType" : { "Ref" : "InstanceType" },
|
||||
"KeyName" : { "Ref" : "KeyName" },
|
||||
"NovaSchedulerHints": [ {"Key": "part", "Value": "long"},
|
||||
{"Key": "ready", "Value": "short"} ],
|
||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
||||
"#!/bin/bash -v\n"
|
||||
]]}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
{
|
||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
||||
|
||||
"Description" : "A Database instance running a local MySQL server",
|
||||
|
||||
"Parameters" : {
|
||||
|
||||
"KeyName" : {
|
||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
||||
"Type" : "String"
|
||||
},
|
||||
|
||||
"InstanceType" : {
|
||||
"Description" : "Database server EC2 instance type",
|
||||
"Type" : "String",
|
||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
||||
},
|
||||
|
||||
"DBName": {
|
||||
"Description" : "The database name",
|
||||
"Type": "String",
|
||||
"MinLength": "1",
|
||||
"MaxLength": "64",
|
||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
||||
},
|
||||
|
||||
"DBUsername": {
|
||||
"NoEcho": "true",
|
||||
"Description" : "The database admin account username",
|
||||
"Type": "String",
|
||||
"MinLength": "1",
|
||||
"MaxLength": "16",
|
||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
||||
},
|
||||
|
||||
"DBPassword": {
|
||||
"NoEcho": "true",
|
||||
"Description" : "The database admin account password",
|
||||
"Type": "String",
|
||||
"MinLength": "1",
|
||||
"MaxLength": "41",
|
||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
||||
},
|
||||
|
||||
"DBRootPassword": {
|
||||
"NoEcho": "true",
|
||||
"Description" : "Root password for MySQL",
|
||||
"Type": "String",
|
||||
"MinLength": "1",
|
||||
"MaxLength": "41",
|
||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
||||
},
|
||||
"LinuxDistribution": {
|
||||
"Description" : "Distribution of choice",
|
||||
"Type": "String",
|
||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ],
|
||||
"Default": "F17"
|
||||
}
|
||||
},
|
||||
|
||||
"Mappings" : {
|
||||
"AWSInstanceType2Arch" : {
|
||||
"t1.micro" : { "Arch" : "32" },
|
||||
"m1.small" : { "Arch" : "32" },
|
||||
"m1.large" : { "Arch" : "64" },
|
||||
"m1.xlarge" : { "Arch" : "64" },
|
||||
"m2.xlarge" : { "Arch" : "64" },
|
||||
"m2.2xlarge" : { "Arch" : "64" },
|
||||
"m2.4xlarge" : { "Arch" : "64" },
|
||||
"c1.medium" : { "Arch" : "32" },
|
||||
"c1.xlarge" : { "Arch" : "64" },
|
||||
"cc1.4xlarge" : { "Arch" : "64" }
|
||||
},
|
||||
"DistroArch2AMI": {
|
||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
||||
}
|
||||
},
|
||||
|
||||
"Resources" : {
|
||||
"MySqlDatabaseServer": {
|
||||
"Type": "AWS::EC2::Instance",
|
||||
"Metadata" : {
|
||||
"AWS::CloudFormation::Init" : {
|
||||
"config" : {
|
||||
"packages" : {
|
||||
"yum" : {
|
||||
"mysql" : [],
|
||||
"mysql-server" : []
|
||||
}
|
||||
},
|
||||
"services" : {
|
||||
"systemd" : {
|
||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Properties": {
|
||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
||||
"InstanceType" : { "Ref" : "InstanceType" },
|
||||
"KeyName" : { "Ref" : "KeyName" },
|
||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
||||
"#!/bin/bash -v\n",
|
||||
|
||||
"# Helper function\n",
|
||||
"function error_exit\n",
|
||||
"{\n",
|
||||
" /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "MySqlWaitHandle" }, "'\n",
|
||||
" exit 1\n",
|
||||
"}\n",
|
||||
|
||||
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
|
||||
" -r MySqlDatabaseServer ",
|
||||
" --region ", { "Ref" : "AWS::Region" },
|
||||
" || error_exit 'Failed to run cfn-init'\n",
|
||||
|
||||
"# Setup MySQL root password and create a user\n",
|
||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"%\"\n",
|
||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
||||
"FLUSH PRIVILEGES;\n",
|
||||
"EXIT\n",
|
||||
"EOF\n",
|
||||
"# All is well so signal success\n",
|
||||
"/opt/aws/bin/cfn-signal -e 0 -r \"MySQL Database setup complete\" '",
|
||||
{ "Ref" : "MySqlWaitHandle" }, "'\n"
|
||||
]]}}
|
||||
}
|
||||
},
|
||||
|
||||
"MySqlWaitHandle" : {
|
||||
"Type" : "AWS::CloudFormation::WaitConditionHandle"
|
||||
},
|
||||
|
||||
"MySqlWaitCondition" : {
|
||||
"Type" : "AWS::CloudFormation::WaitCondition",
|
||||
"DependsOn" : "MySqlDatabaseServer",
|
||||
"Properties" : {
|
||||
"Handle" : {"Ref" : "MySqlWaitHandle"},
|
||||
"Timeout" : "600"
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"Outputs" : {
|
||||
"PublicIp": {
|
||||
"Value": { "Fn::GetAtt" : [ "MySqlDatabaseServer", "PublicIp" ] },
|
||||
"Description": "Database server IP"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,291 @@
|
||||
{
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "Template for setting up an OpenShift Origin environment",
|
||||
"Parameters": {
|
||||
"KeyName": {
|
||||
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
||||
"Type": "String",
|
||||
"MinLength": "1",
|
||||
"MaxLength": "64",
|
||||
"AllowedPattern": "[-_ a-zA-Z0-9]*"
|
||||
},
|
||||
"Prefix": {
|
||||
"Description": "Your DNS Prefix",
|
||||
"Type": "String",
|
||||
"Default": "example.com"
|
||||
},
|
||||
"DnsSecKey": {
|
||||
"Description": "Bind DNS-Sec TSIG key",
|
||||
"Type": "String",
|
||||
"NoEcho": "TRUE"
|
||||
},
|
||||
"UpstreamDNS": {
|
||||
"Description": "Upstream DNS server",
|
||||
"Type": "String",
|
||||
"Default": "8.8.8.8"
|
||||
}
|
||||
},
|
||||
"Mappings": {
|
||||
"JeosImages": {
|
||||
"Broker": {
|
||||
"Image": "F18-x86_64-openshift-origin-broker-cfntools"
|
||||
},
|
||||
"Node": {
|
||||
"Image": "F18-x86_64-openshift-origin-node-cfntools"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Resources": {
|
||||
"OpenShiftOriginSecurityGroup": {
|
||||
"Type": "AWS::EC2::SecurityGroup",
|
||||
"Properties": {
|
||||
"GroupDescription": "Standard firewall rules",
|
||||
"SecurityGroupIngress": [
|
||||
{
|
||||
"IpProtocol": "udp",
|
||||
"FromPort": "53",
|
||||
"ToPort": "53",
|
||||
"CidrIp": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"IpProtocol": "tcp",
|
||||
"FromPort": "53",
|
||||
"ToPort": "53",
|
||||
"CidrIp": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"IpProtocol": "tcp",
|
||||
"FromPort": "22",
|
||||
"ToPort": "22",
|
||||
"CidrIp": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"IpProtocol": "tcp",
|
||||
"FromPort": "80",
|
||||
"ToPort": "80",
|
||||
"CidrIp": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"IpProtocol": "tcp",
|
||||
"FromPort": "443",
|
||||
"ToPort": "443",
|
||||
"CidrIp": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"IpProtocol": "tcp",
|
||||
"FromPort": "8000",
|
||||
"ToPort": "8000",
|
||||
"CidrIp": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"IpProtocol": "tcp",
|
||||
"FromPort": "8443",
|
||||
"ToPort": "8443",
|
||||
"CidrIp": "0.0.0.0/0"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"brokerWaitHandle": {
|
||||
"Type": "AWS::CloudFormation::WaitConditionHandle"
|
||||
},
|
||||
"brokerWaitCondition": {
|
||||
"Type": "AWS::CloudFormation::WaitCondition",
|
||||
"DependsOn": "BrokerInstance",
|
||||
"Properties": {
|
||||
"Handle": {
|
||||
"Ref": "brokerWaitHandle"
|
||||
},
|
||||
"Timeout": "6000"
|
||||
}
|
||||
},
|
||||
"BrokerInstance": {
|
||||
"Type": "AWS::EC2::Instance",
|
||||
"Properties": {
|
||||
"ImageId": {
|
||||
"Fn::FindInMap": [ "JeosImages", "Broker", "Image" ]
|
||||
},
|
||||
"InstanceType": "m1.medium",
|
||||
"KeyName": {
|
||||
"Ref": "KeyName"
|
||||
},
|
||||
"SecurityGroups": [
|
||||
{
|
||||
"Ref": "OpenShiftOriginSecurityGroup"
|
||||
}
|
||||
],
|
||||
"Tags": [
|
||||
{
|
||||
"Key": "Name",
|
||||
"Value": {
|
||||
"Fn::Join": [ "-", [ "openshift", { "Ref": "Prefix" }, "broker" ] ]
|
||||
}
|
||||
}
|
||||
],
|
||||
"UserData": {
|
||||
"Fn::Base64": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"#!/bin/bash -x", "\n",
|
||||
"cat << EOF > /root/configure.pp\n",
|
||||
"\\$my_hostname=\"\\${ec2_instance_id}.", { "Ref": "Prefix" }, "\"\n",
|
||||
"file { \"update network settings - hostname\":", "\n",
|
||||
" path => \"/etc/sysconfig/network\",\n",
|
||||
" content => \"NETWORKING=yes\\nNETWORKING_IPV6=no\\nHOSTNAME=\\${my_hostname}\"\n",
|
||||
"}\n",
|
||||
"exec { \"set hostname\":\n",
|
||||
" command => \"/bin/hostname \\${my_hostname} ; echo \\${my_hostname} > /etc/hostname\"\n",
|
||||
"}\n",
|
||||
"augeas{ \"etc hosts setup\" :\n",
|
||||
" context => \"/files/etc/hosts\",\n",
|
||||
" changes => [\n",
|
||||
" \"set 01/ipaddr \\${ipaddress}\",\n",
|
||||
" \"set 01/canonical \\${my_hostname}\",\n",
|
||||
" ],\n",
|
||||
"}\n",
|
||||
"augeas{ \"network peerdns setup\" :\n",
|
||||
" context => \"/files/etc/sysconfig/network-scripts/ifcfg-eth0\",\n",
|
||||
" changes => [\n",
|
||||
" \"set PEERDNS no\",\n",
|
||||
" ],\n",
|
||||
"}\n",
|
||||
"class { \"openshift_origin\" :\n",
|
||||
" node_fqdn => \\$my_hostname,\n",
|
||||
" cloud_domain => \"", { "Ref": "Prefix" }, "\",", "\n",
|
||||
" named_tsig_priv_key => \"", { "Ref": "DnsSecKey" }, "\",", "\n",
|
||||
" dns_servers => [\"", { "Ref": "UpstreamDNS" }, "\"],\n",
|
||||
" os_unmanaged_users => [\"ec2-user\"],\n",
|
||||
" enable_network_services => true,\n",
|
||||
" configure_firewall => false,\n",
|
||||
" configure_ntp => true,\n",
|
||||
" configure_activemq => true,\n",
|
||||
" configure_qpid => false,\n",
|
||||
" configure_mongodb => true,\n",
|
||||
" configure_named => true,\n",
|
||||
" configure_broker => true,\n",
|
||||
" configure_console => true,\n",
|
||||
" configure_node => false,\n",
|
||||
" development_mode => true,\n",
|
||||
" named_ipaddress => \\$ipaddress,\n",
|
||||
" mongodb_fqdn => \\$my_hostname,\n",
|
||||
" mq_fqdn => \\$my_hostname,\n",
|
||||
" broker_fqdn => \\$my_hostname,\n",
|
||||
"}\n",
|
||||
"EOF\n",
|
||||
"puppet module install openshift/openshift_origin", "\n",
|
||||
"puppet apply --verbose /root/configure.pp | tee /var/log/configure_openshift.log", "\n",
|
||||
"service network restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service mongod restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service activemq restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service httpd restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service openshift-broker restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service openshift-console restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service named restart | tee /var/log/configure_openshift.log;\n",
|
||||
"export EC2_INSTANCE_ID=\"`facter ec2_instance_id`\"\n",
|
||||
"export IP_ADDRESS=\"`facter ipaddress`\"\n",
|
||||
"cat << _EOF > /root/nsupdate.cmd\n",
|
||||
"key ", { "Ref": "Prefix" }," ",{ "Ref": "DnsSecKey" },"\n",
|
||||
"server ${IP_ADDRESS} 53\n",
|
||||
"update delete ${EC2_INSTANCE_ID}.",{ "Ref": "Prefix" }," A\n",
|
||||
"update add ${EC2_INSTANCE_ID}.",{ "Ref": "Prefix" }," 180 A ${IP_ADDRESS}\n",
|
||||
"send\n",
|
||||
"_EOF\n",
|
||||
"cat /root/nsupdate.cmd | nsupdate\n",
|
||||
"# All is well so signal success\n",
|
||||
"/opt/aws/bin/cfn-signal -e 0 -r \"Broker setup complete\" \"", { "Ref": "brokerWaitHandle" }, "\"\n"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"NodeInstance": {
|
||||
"Type": "AWS::EC2::Instance",
|
||||
"DependsOn": "brokerWaitCondition",
|
||||
"Properties": {
|
||||
"ImageId": {
|
||||
"Fn::FindInMap": [ "JeosImages", "Node", "Image" ]
|
||||
},
|
||||
"InstanceType": "m1.medium",
|
||||
"KeyName": { "Ref": "KeyName" },
|
||||
"SecurityGroups": [ { "Ref": "OpenShiftOriginSecurityGroup" } ],
|
||||
"Tags": [ { "Key": "Name", "Value": { "Fn::Join": [ "-", [ "openshift", { "Ref": "Prefix" }, "node" ] ] } } ],
|
||||
"UserData": {
|
||||
"Fn::Base64": {
|
||||
"Fn::Join": [
|
||||
"",
|
||||
[
|
||||
"#!/bin/bash -x", "\n",
|
||||
"cat << EOF > /root/configure.pp\n",
|
||||
"\\$my_hostname=\"\\${ec2_instance_id}.", { "Ref": "Prefix" }, "\"\n",
|
||||
"file { \"update network settings - hostname\":", "\n",
|
||||
" path => \"/etc/sysconfig/network\",\n",
|
||||
" content => \"NETWORKING=yes\\nNETWORKING_IPV6=no\\nHOSTNAME=\\${my_hostname}\"\n",
|
||||
"}\n",
|
||||
"exec { \"set hostname\":\n",
|
||||
" command => \"/bin/hostname \\${my_hostname} ; echo \\${my_hostname} > /etc/hostname\"\n",
|
||||
"}\n",
|
||||
"augeas{ \"etc hosts setup\" :\n",
|
||||
" context => \"/files/etc/hosts\",\n",
|
||||
" changes => [\n",
|
||||
" \"set 01/ipaddr \\${ipaddress}\",\n",
|
||||
" \"set 01/canonical \\${my_hostname}\",\n",
|
||||
" ],\n",
|
||||
"}\n",
|
||||
"augeas{ \"network peerdns setup\" :\n",
|
||||
" context => \"/files/etc/sysconfig/network-scripts/ifcfg-eth0\",\n",
|
||||
" changes => [\n",
|
||||
" \"set PEERDNS no\",\n",
|
||||
" ],\n",
|
||||
"}\n",
|
||||
"class { \"openshift_origin\" :\n",
|
||||
" node_fqdn => \\$my_hostname,\n",
|
||||
" cloud_domain => \"", { "Ref": "Prefix" }, "\",", "\n",
|
||||
" named_tsig_priv_key => \"", { "Ref": "DnsSecKey" }, "\",", "\n",
|
||||
" dns_servers => [\"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\"],\n",
|
||||
" os_unmanaged_users => [\"ec2-user\"],\n",
|
||||
" enable_network_services => true,\n",
|
||||
" configure_firewall => false,\n",
|
||||
" configure_ntp => true,\n",
|
||||
" configure_activemq => false,\n",
|
||||
" configure_qpid => false,\n",
|
||||
" configure_mongodb => false,\n",
|
||||
" configure_named => false,\n",
|
||||
" configure_broker => false,\n",
|
||||
" configure_console => false,\n",
|
||||
" configure_node => true,\n",
|
||||
" development_mode => true,\n",
|
||||
" named_ipaddress => \"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\",\n",
|
||||
" mongodb_fqdn => \"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\",\n",
|
||||
" mq_fqdn => \"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\",\n",
|
||||
" broker_fqdn => \"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\",\n",
|
||||
"}\n",
|
||||
"EOF\n",
|
||||
"puppet apply --verbose /root/configure.pp | tee /var/log/configure_openshift.log;", "\n",
|
||||
"service network restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service cgconfig restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service cgred restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service openshift-cgroups restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service openshift-node-web-proxy restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service mcollective restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service httpd restart | tee /var/log/configure_openshift.log;\n",
|
||||
"service sshd restart | tee /var/log/configure_openshift.log;\n",
|
||||
"export EC2_INSTANCE_ID=\"`facter ec2_instance_id`\"\n",
|
||||
"export IP_ADDRESS=\"`facter ipaddress`\"\n",
|
||||
"cat << _EOF > /root/nsupdate.cmd\n",
|
||||
"key ", { "Ref": "Prefix" }," ",{ "Ref": "DnsSecKey" },"\n",
|
||||
"server ",{ "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }," 53\n",
|
||||
"update delete ${EC2_INSTANCE_ID}.",{ "Ref": "Prefix" }," A\n",
|
||||
"update add ${EC2_INSTANCE_ID}.",{ "Ref": "Prefix" }," 180 A ${IP_ADDRESS}\n",
|
||||
"send\n",
|
||||
"_EOF\n",
|
||||
"cat /root/nsupdate.cmd | nsupdate\n"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
{
|
||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
||||
|
||||
"Description": "Sample template to bring up Puppet Master instance that can be used to bootstrap and manage Puppet Clients. The Puppet Master is populated from an embedded template that defines the set of applications to load. **WARNING** This template creates one or more Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template.",
|
||||
|
||||
"Parameters" : {
|
||||
"InstanceType" : {
|
||||
"Description" : "WebServer EC2 instance type",
|
||||
"Type" : "String",
|
||||
"Default" : "m1.large",
|
||||
"AllowedValues" : [ "t1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m2.xlarge","m2.2xlarge","m2.4xlarge","c1.medium","c1.xlarge","cc1.4xlarge","cc2.8xlarge","cg1.4xlarge"],
|
||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
||||
},
|
||||
"KeyName" : {
|
||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the PuppetMaster",
|
||||
"Type" : "String"
|
||||
},
|
||||
"ContentManifest" : {
|
||||
"Default" : "/wordpress/: { include wordpress }",
|
||||
"Description" : "Manifest of roles to add to nodes.pp",
|
||||
"Type" : "String"
|
||||
},
|
||||
"ContentLocation" : {
|
||||
"Default" : "https://s3.amazonaws.com/cloudformation-examples/wordpress-puppet-config.tar.gz",
|
||||
"Description" : "Location of package (Zip, GZIP or Git repository URL) that includes the PuppetMaster content",
|
||||
"Type" : "String"
|
||||
},
|
||||
"LinuxDistribution": {
|
||||
"Default": "F17",
|
||||
"Description" : "Distribution of choice",
|
||||
"Type": "String",
|
||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
||||
}
|
||||
},
|
||||
"Mappings" : {
|
||||
"AWSInstanceType2Arch" : {
|
||||
"t1.micro" : { "Arch" : "32" },
|
||||
"m1.small" : { "Arch" : "32" },
|
||||
"m1.large" : { "Arch" : "64" },
|
||||
"m1.xlarge" : { "Arch" : "64" },
|
||||
"m2.xlarge" : { "Arch" : "64" },
|
||||
"m2.2xlarge" : { "Arch" : "64" },
|
||||
"m2.4xlarge" : { "Arch" : "64" },
|
||||
"c1.medium" : { "Arch" : "32" },
|
||||
"c1.xlarge" : { "Arch" : "64" },
|
||||
"cc1.4xlarge" : { "Arch" : "64" }
|
||||
},
|
||||
"DistroArch2AMI": {
|
||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
||||
}
|
||||
},
|
||||
"Resources" : {
|
||||
"CFNInitUser" : {
|
||||
"Type" : "AWS::IAM::User"
|
||||
},
|
||||
|
||||
"CFNKeys" : {
|
||||
"Type" : "AWS::IAM::AccessKey",
|
||||
"Properties" : {
|
||||
"UserName" : { "Ref": "CFNInitUser" }
|
||||
}
|
||||
},
|
||||
|
||||
"PuppetMasterInstance" : {
|
||||
"Type" : "AWS::EC2::Instance",
|
||||
"Metadata" : {
|
||||
"AWS::CloudFormation::Init" : {
|
||||
"config" : {
|
||||
"packages" : {
|
||||
"yum" : {
|
||||
"puppet" : [],
|
||||
"puppet-server" : [],
|
||||
"ruby-devel" : [],
|
||||
"gcc" : [],
|
||||
"make" : [],
|
||||
"rubygems" : []
|
||||
},
|
||||
"rubygems" : {
|
||||
"json" : []
|
||||
}
|
||||
},
|
||||
"sources" : {
|
||||
"/etc/puppet" : { "Ref" : "ContentLocation" }
|
||||
},
|
||||
"files" : {
|
||||
"/etc/yum.repos.d/epel.repo" : {
|
||||
"source" : "https://s3.amazonaws.com/cloudformation-examples/enable-epel-on-amazon-linux-ami",
|
||||
"mode" : "000644",
|
||||
"owner" : "root",
|
||||
"group" : "root"
|
||||
},
|
||||
"/etc/puppet/autosign.conf" : {
|
||||
"content" : "*.internal\n",
|
||||
"mode" : "100644",
|
||||
"owner" : "root",
|
||||
"group" : "wheel"
|
||||
},
|
||||
"/etc/puppet/fileserver.conf" : {
|
||||
"content" : "[modules]\n allow *.internal\n",
|
||||
"mode" : "100644",
|
||||
"owner" : "root",
|
||||
"group" : "wheel"
|
||||
},
|
||||
"/etc/puppet/puppet.conf" : {
|
||||
"content" : { "Fn::Join" : ["", [
|
||||
"[main]\n",
|
||||
" logdir=/var/log/puppet\n",
|
||||
" rundir=/var/run/puppet\n",
|
||||
" ssldir=$vardir/ssl\n",
|
||||
" pluginsync=true\n",
|
||||
"[agent]\n",
|
||||
" classfile=$vardir/classes.txt\n",
|
||||
" localconfig=$vardir/localconfig\n"]] },
|
||||
"mode" : "000644",
|
||||
"owner" : "root",
|
||||
"group" : "root"
|
||||
},
|
||||
"/etc/puppet/modules/cfn/manifests/init.pp" : {
|
||||
"content" : "class cfn {}",
|
||||
"mode" : "100644",
|
||||
"owner" : "root",
|
||||
"group" : "wheel"
|
||||
},
|
||||
"/etc/puppet/modules/cfn/lib/facter/cfn.rb" : {
|
||||
"source" : "https://s3.amazonaws.com/cloudformation-examples/cfn-facter-plugin.rb",
|
||||
"mode" : "100644",
|
||||
"owner" : "root",
|
||||
"group" : "wheel"
|
||||
},
|
||||
"/etc/puppet/manifests/nodes.pp" : {
|
||||
"content" : {"Fn::Join" : ["", [
|
||||
"node basenode {\n",
|
||||
" include cfn\n",
|
||||
"}\n",
|
||||
"node /^.*internal$/ inherits basenode {\n",
|
||||
" case $cfn_roles {\n",
|
||||
" ", { "Ref" : "ContentManifest" }, "\n",
|
||||
" }\n",
|
||||
"}\n"]]},
|
||||
"mode" : "100644",
|
||||
"owner" : "root",
|
||||
"group" : "wheel"
|
||||
},
|
||||
"/etc/puppet/manifests/site.pp" : {
|
||||
"content" : "import \"nodes\"\n",
|
||||
"mode" : "100644",
|
||||
"owner" : "root",
|
||||
"group" : "wheel"
|
||||
}
|
||||
},
|
||||
"services" : {
|
||||
"sysvinit" : {
|
||||
"puppetmaster" : {
|
||||
"enabled" : "true",
|
||||
"ensureRunning" : "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Properties" : {
|
||||
"InstanceType" : { "Ref" : "InstanceType" },
|
||||
"SecurityGroups" : [ { "Ref" : "PuppetGroup" } ],
|
||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
||||
"KeyName" : { "Ref" : "KeyName" },
|
||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
||||
"#!/bin/bash\n",
|
||||
"yum update -y aws-cfn-bootstrap\n",
|
||||
|
||||
"/opt/aws/bin/cfn-init --region ", { "Ref" : "AWS::Region" },
|
||||
" -s ", { "Ref" : "AWS::StackName" }, " -r PuppetMasterInstance ",
|
||||
" --access-key ", { "Ref" : "CFNKeys" },
|
||||
" --secret-key ", { "Fn::GetAtt" : ["CFNKeys", "SecretAccessKey"]}, "\n",
|
||||
"/opt/aws/bin/cfn-signal -e $? '", { "Ref" : "PuppetMasterWaitHandle" }, "'\n"]]}}
|
||||
}
|
||||
},
|
||||
|
||||
"EC2SecurityGroup" : {
|
||||
"Type" : "AWS::EC2::SecurityGroup",
|
||||
"Properties" : {
|
||||
"GroupDescription" : "Group for clients to communicate with Puppet Master"
|
||||
}
|
||||
},
|
||||
|
||||
"PuppetGroup" : {
|
||||
"Type" : "AWS::EC2::SecurityGroup",
|
||||
"Properties" : {
|
||||
"GroupDescription" : "Group for puppet communication",
|
||||