Permalink
Browse files

gen-pack to get to a 6 pack of membase

  • Loading branch information...
1 parent 1dace25 commit 777acd5b06fa2c7f4ac57b2b90df2be2830ec479 @steveyen steveyen committed Jul 15, 2011
Showing with 6,668 additions and 9 deletions.
  1. +14 −0 Makefile
  2. +13 −0 gen-pack
  3. +146 −0 membase.erb
  4. +15 −9 membase.template → packs/1-pack-membase
  5. +390 −0 packs/10-pack-membase
  6. +2,820 −0 packs/100-pack-membase
  7. +174 −0 packs/2-pack-membase
  8. +660 −0 packs/20-pack-membase
  9. +201 −0 packs/3-pack-membase
  10. +228 −0 packs/4-pack-membase
  11. +255 −0 packs/5-pack-membase
  12. +1,470 −0 packs/50-pack-membase
  13. +282 −0 packs/6-pack-membase
View
@@ -0,0 +1,14 @@
+all: gen-membase-packs
+
+gen-membase-packs:
+ ./gen-pack membase.erb 1 > packs/1-pack-membase
+ ./gen-pack membase.erb 2 > packs/2-pack-membase
+ ./gen-pack membase.erb 3 > packs/3-pack-membase
+ ./gen-pack membase.erb 4 > packs/4-pack-membase
+ ./gen-pack membase.erb 5 > packs/5-pack-membase
+ ./gen-pack membase.erb 6 > packs/6-pack-membase
+ ./gen-pack membase.erb 10 > packs/10-pack-membase
+ ./gen-pack membase.erb 20 > packs/20-pack-membase
+ ./gen-pack membase.erb 50 > packs/50-pack-membase
+ ./gen-pack membase.erb 100 > packs/100-pack-membase
+
View
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+
+require 'erb'
+
+# Usage:
+# gen-pack some-template.erb 1
+# gen-pack some-template.erb 5
+#
+erb_path = ARGV[0]
+num_instances = ARGV[1].to_i
+
+print ERB.new(IO.read(erb_path)).result(binding)
+print "\n"
View
@@ -0,0 +1,146 @@
+{
+ "AWSTemplateFormatVersion" : "2010-09-09",
+ "Description" : "Template for Membase Server on EC2",
+ "Parameters" : {
+ "KeyName" : {
+ "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
+ "Type" : "String"
+ },
+ "MembasePackageURL" : {
+ "Description" : "URL to Membase software package",
+ "Type" : "String",
+ "Default" : "http://packages.couchbase.com/releases/1.7.0/membase-server-community_x86_1.7.0.rpm"
+ },
+ "RESTPassword" : {
+ "NoEcho": "true",
+ "Description" : "Password for REST Administrator API and web-console interface",
+ "Type" : "String"
+ },
+ "RAMPerServer" : {
+ "Description" : "Maximum RAM quota in MB for each node in the cluster",
+ "Type" : "Number",
+ "Default" : "500",
+ "MinValue" : "200"
+ },
+ "RAMForDefaultBucket" : {
+ "Description" : "Maximum RAM quota in MB for the default bucket. Should be <= RAMPerServer",
+ "Type" : "Number",
+ "Default" : "500",
+ "MinValue" : "0"
+ },
+ "ExistingClusterHostPort" : {
+ "Description" : "Optional 'host:port', if you want to join new node(s) to an existing cluster node",
+ "Type" : "String",
+ "Default" : "host:port"
+ }
+ },
+
+ "Mappings" : {
+ "RegionMap" : {
+ "us-east-1" : {"AMI" : "ami-8c1fece5"},
+ "us-west-1" : {"AMI" : "ami-3bc9997e"},
+ "eu-west-1" : {"AMI" : "ami-47cefa33"},
+ "ap-southeast-1" : {"AMI" : "ami-6af08e38"},
+ "ap-northeast-1" : {"AMI" : "ami-300ca731"}
+ }
+ },
+
+ "Resources" : {
+ <% for i in (0..(num_instances - 1)) %>
+ "Membase<%= i %>" : {
+ "Type" : "AWS::EC2::Instance",
+ "Properties" : {
+ "KeyName" : { "Ref" : "KeyName" },
+ "SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
+ "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
+ "UserData" : { "Fn::Base64" : { "Fn::Join" : ["",[
+ "#!/bin/bash -ex","\n",
+ "yum -y install openssl098e","\n",
+ "wget ", { "Ref" : "MembasePackageURL" },"\n",
+ "rpm -i membase-server-community*.rpm","\n",
+ "sleep 5","\n",
+ "/opt/membase/bin/membase cluster-init -c 127.0.0.1",
+ " --cluster-init-username=Administrator",
+ " --cluster-init-password=", { "Ref" : "RESTPassword" },
+ " --cluster-init-ramsize=", { "Ref" : "RAMPerServer" },"\n",
+ "/opt/membase/bin/membase bucket-create -c 127.0.0.1",
+ " -u Administrator -p ", { "Ref" : "RESTPassword" },
+ " --bucket=default",
+ " --bucket-type=membase",
+ " --bucket-password=",
+ " --bucket-ramsize=", { "Ref" : "RAMForDefaultBucket" },
+ " --bucket-replica=1"
+ <% if i == 0 %>
+ ,"\n",
+ "curl -X PUT -H 'Content-Type:' --data-binary '{\"Status\" : \"SUCCESS\",",
+ "\"Reason\" : \"Membase node is ready\",",
+ "\"UniqueId\" : \"membase\",",
+ "\"Data\" : \"Done\"}' ",
+ "\"", {"Ref" : "WaitForInstanceWaitHandle"},"\"\n" ]]}}
+ <% end %>
+ }
+ },
+ <% end %>
+
+ "InstanceSecurityGroup" : {
+ "Type" : "AWS::EC2::SecurityGroup",
+ "Properties" : {
+ "GroupDescription" :
+ "Enable SSH access via port 22, web access to 8091, membase/memcached protocol access to 11211 and 11210, and erlang access",
+ "SecurityGroupIngress" : [ {
+ "IpProtocol" : "tcp",
+ "FromPort" : "22",
+ "ToPort" : "22",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "8091",
+ "ToPort" : "8091",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "11211",
+ "ToPort" : "11211",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "11210",
+ "ToPort" : "11210",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "4369",
+ "ToPort" : "4369",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "21100",
+ "ToPort" : "21299",
+ "CidrIp" : "0.0.0.0/0"
+ } ]
+ }
+ },
+
+ "WaitForInstanceWaitHandle" : {
+ "Type" : "AWS::CloudFormation::WaitConditionHandle",
+ "Properties" : {
+ }
+ },
+
+ "WaitForInstance" : {
+ "Type" : "AWS::CloudFormation::WaitCondition",
+ "DependsOn" : "Membase0",
+ "Properties" : {
+ "Handle" : {"Ref" : "WaitForInstanceWaitHandle"},
+ "Timeout" : "600"
+ }
+ }
+ },
+
+ "Outputs" : {
+ "RESTWebConsoleURL" : {
+ "Description" : "The URL for the newly created Membase node(s)",
+ "Value" : { "Fn::Join" : ["", [ "http://", { "Fn::GetAtt" : [ "Membase0", "PublicIp" ] }, ":8091" ]]}
+ }
+ }
+}
@@ -46,7 +46,8 @@
},
"Resources" : {
- "Ec2Instance" : {
+
+ "Membase0" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"KeyName" : { "Ref" : "KeyName" },
@@ -68,14 +69,18 @@
" --bucket-type=membase",
" --bucket-password=",
" --bucket-ramsize=", { "Ref" : "RAMForDefaultBucket" },
- " --bucket-replica=1","\n",
- "curl -X PUT -H 'Content-Type:' --data-binary '{\"Status\" : \"SUCCESS\",",
- "\"Reason\" : \"Membase node is ready\",",
- "\"UniqueId\" : \"membase\",",
- "\"Data\" : \"Done\"}' ",
- "\"", {"Ref" : "WaitForInstanceWaitHandle"},"\"\n" ]]}}
+ " --bucket-replica=1"
+
+ ,"\n",
+ "curl -X PUT -H 'Content-Type:' --data-binary '{\"Status\" : \"SUCCESS\",",
+ "\"Reason\" : \"Membase node is ready\",",
+ "\"UniqueId\" : \"membase\",",
+ "\"Data\" : \"Done\"}' ",
+ "\"", {"Ref" : "WaitForInstanceWaitHandle"},"\"\n" ]]}}
+
}
},
+
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
@@ -124,7 +129,7 @@
"WaitForInstance" : {
"Type" : "AWS::CloudFormation::WaitCondition",
- "DependsOn" : "Ec2Instance",
+ "DependsOn" : "Membase0",
"Properties" : {
"Handle" : {"Ref" : "WaitForInstanceWaitHandle"},
"Timeout" : "600"
@@ -135,7 +140,8 @@
"Outputs" : {
"RESTWebConsoleURL" : {
"Description" : "The URL for the newly created Membase node(s)",
- "Value" : { "Fn::Join" : ["", [ "http://", { "Fn::GetAtt" : [ "Ec2Instance", "PublicIp" ] }, ":8091" ]]}
+ "Value" : { "Fn::Join" : ["", [ "http://", { "Fn::GetAtt" : [ "Membase0", "PublicIp" ] }, ":8091" ]]}
}
}
}
+
Oops, something went wrong.

0 comments on commit 777acd5

Please sign in to comment.