capistrano-scalr 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/README.markdown +60 -0
- data/Rakefile +2 -0
- data/capistrano-scalr.gemspec +24 -0
- data/lib/capistrano-scalr/version.rb +5 -0
- data/lib/capistrano-scalr.rb +81 -0
- metadata +102 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
## capistrano-scalr
|
2
|
+
|
3
|
+
The capistrano-scalr gem conveniently packages modified versions of Donovan Bray's [Scalr capistrano recipes](http://groups.google.com/group/scalr-discuss/web/scalr-with-capistrano).
|
4
|
+
|
5
|
+
## Installation and Usage
|
6
|
+
|
7
|
+
First, install the gem:
|
8
|
+
|
9
|
+
gem install capistrano-scalr
|
10
|
+
|
11
|
+
After gem installation, add the following to your deploy.rb:
|
12
|
+
|
13
|
+
set :gateway, "<gateway_host>"
|
14
|
+
role :gw, gateway, :no_release => true
|
15
|
+
set :gateway_type, "<centos|ubuntu>"
|
16
|
+
require 'capistrano-scalr'
|
17
|
+
|
18
|
+
The above will automatically connect to your scalr farm using the gateway you specify (the primary database server is a logical choice, since it usually stays pretty static), enumerate the instances in your farm, then create the following roles with the scalr hosts contained within:
|
19
|
+
|
20
|
+
- lb
|
21
|
+
- web
|
22
|
+
- app
|
23
|
+
- db
|
24
|
+
- memcached
|
25
|
+
|
26
|
+
I also recommend that you use ssh-agent on your development workstation, enable agent forwarding on your scalr hosts, and set this in deploy.rb:
|
27
|
+
|
28
|
+
set :ssh_options, { :forward_agent => true }
|
29
|
+
|
30
|
+
Once you have completed the above, you can test for proper operation by running the scalr:enum cap task:
|
31
|
+
|
32
|
+
$ cap scalr:enum
|
33
|
+
* executing `scalr:enum'
|
34
|
+
** SCALR Hosts:
|
35
|
+
* executing "find /etc/aws/hosts | cut -d\"/\" -f5,6 | grep \"/\""
|
36
|
+
servers: ["scalrgw.domain.net"]
|
37
|
+
* establishing connection to gateway `scalrgw.domain.net'
|
38
|
+
* Creating gateway using scalrgw.domain.net
|
39
|
+
* establishing connection to `scalrgw.domain.net' via gateway
|
40
|
+
[scalrgw.domain.net] executing command
|
41
|
+
** app/10.0.0.1
|
42
|
+
** app/10.0.0.2
|
43
|
+
** www/10.0.0.3
|
44
|
+
** www/10.0.0.4
|
45
|
+
** mysql/10.0.0.5
|
46
|
+
** mysql/10.0.0.6
|
47
|
+
** mysql-slave/10.0.0.5
|
48
|
+
** mysql-master/10.0.0.6
|
49
|
+
command finished
|
50
|
+
|
51
|
+
You should now be able to deploy to your scalr farm via capistrano, and not have to worry about having to adjust your deploy.rb when instances change.
|
52
|
+
|
53
|
+
## TODO
|
54
|
+
|
55
|
+
- Auto-detect gateway platform
|
56
|
+
|
57
|
+
## Credits
|
58
|
+
|
59
|
+
- Thanks to [Donovan Bray](http://www.donovanbray.com), the original author of the Scalr capistrano recipes on which this gem's recipes are based
|
60
|
+
- Thanks to [Jamis Buck](http://weblog.jamisbuck.org) for the fantastic [Capistrano](http://capify.org)
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/capistrano-scalr/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "capistrano-scalr"
|
6
|
+
s.version = Capistrano::Scalr::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = []
|
9
|
+
s.email = []
|
10
|
+
s.homepage = "http://rubygems.org/gems/capistrano-scalr"
|
11
|
+
s.summary = "Capistrano recipes for deploying to Scalr"
|
12
|
+
s.description = "Capistrano recipes for deploying to Scalr"
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "capistrano-scalr"
|
16
|
+
|
17
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
18
|
+
|
19
|
+
s.add_dependency "capistrano", ">= 2.0.0"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
23
|
+
s.require_path = 'lib'
|
24
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# module Capistrano
|
2
|
+
# module Scalr
|
3
|
+
# # Your code goes here...
|
4
|
+
# end
|
5
|
+
# end
|
6
|
+
|
7
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
8
|
+
abort "capistrano/scalr requires Capistrano 2"
|
9
|
+
end
|
10
|
+
|
11
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
12
|
+
|
13
|
+
###
|
14
|
+
# Code below is stolen from Jamis' capistrano-ext
|
15
|
+
def _cset(name, *args, &block)
|
16
|
+
unless exists?(name)
|
17
|
+
set(name, *args, &block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# =========================================================================
|
22
|
+
# These variables MUST be set in the client capfiles. If they are not set,
|
23
|
+
# the deploy will fail with an error.
|
24
|
+
# =========================================================================
|
25
|
+
|
26
|
+
_cset(:gateway) { abort "Please specify the instance to use as a gateway. Example: set :gateway, 'foo'" }
|
27
|
+
_cset(:gateway_type) { abort "Please specify the type of instance for your gateway. Example: set :gateway_type, 'ubuntu'" }
|
28
|
+
###
|
29
|
+
|
30
|
+
###
|
31
|
+
# Modified recipes, initially taken from http://groups.google.com/group/scalr-discuss/web/scalr-with-capistrano
|
32
|
+
namespace :scalr do
|
33
|
+
desc "Enumerate SCALR hosts"
|
34
|
+
# task :enum, :roles=>[:db], :only => { :primary => true } do
|
35
|
+
task :enum, :roles=>[:gw] do
|
36
|
+
hosts = Hash.new
|
37
|
+
logger.info "SCALR Hosts:"
|
38
|
+
if (gateway_type == 'centos')
|
39
|
+
hosts_cmd = 'find /etc/scalr/private.d/hosts | cut -d"/" -f6,7 | grep "/"'
|
40
|
+
elsif (gateway_type == 'ubuntu')
|
41
|
+
hosts_cmd = 'find /etc/aws/hosts | cut -d"/" -f5,6 | grep "/"'
|
42
|
+
else
|
43
|
+
abort "You must specify a gateway type"
|
44
|
+
end
|
45
|
+
run hosts_cmd, :pty => true do |ch, stream, out|
|
46
|
+
next if out.chomp == ''
|
47
|
+
logger.info out.sub(/\//,' ')
|
48
|
+
out.split("\r\n").each do |host|
|
49
|
+
host=host.split("/")
|
50
|
+
(hosts[host[0]] ||= []) << host[1]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
if hosts.has_key?('mysql')
|
54
|
+
if hosts['mysql'].size > 1
|
55
|
+
hosts['mysql'] = hosts['mysql'] - hosts['mysql-master']
|
56
|
+
end
|
57
|
+
end
|
58
|
+
set :scalr_hosts, hosts
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
scalr.enum
|
63
|
+
|
64
|
+
role :lb, :no_release => true do
|
65
|
+
scalr_hosts['loadbalancer']
|
66
|
+
end
|
67
|
+
role :web, :no_release => true do
|
68
|
+
scalr_hosts['www']
|
69
|
+
end
|
70
|
+
role :app do
|
71
|
+
scalr_hosts['app']
|
72
|
+
end
|
73
|
+
role :db, :no_release => true do
|
74
|
+
scalr_hosts['mysql']
|
75
|
+
end
|
76
|
+
role :memcached, :no_release => true do
|
77
|
+
scalr_hosts['memcached']
|
78
|
+
end
|
79
|
+
###
|
80
|
+
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-scalr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
|
+
platform: ruby
|
11
|
+
authors: []
|
12
|
+
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-10-08 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bundler
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: capistrano
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 2
|
45
|
+
- 0
|
46
|
+
- 0
|
47
|
+
version: 2.0.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
description: Capistrano recipes for deploying to Scalr
|
51
|
+
email: []
|
52
|
+
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files: []
|
58
|
+
|
59
|
+
files:
|
60
|
+
- .gitignore
|
61
|
+
- Gemfile
|
62
|
+
- README.markdown
|
63
|
+
- Rakefile
|
64
|
+
- capistrano-scalr.gemspec
|
65
|
+
- lib/capistrano-scalr.rb
|
66
|
+
- lib/capistrano-scalr/version.rb
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: http://rubygems.org/gems/capistrano-scalr
|
69
|
+
licenses: []
|
70
|
+
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 1
|
91
|
+
- 3
|
92
|
+
- 6
|
93
|
+
version: 1.3.6
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project: capistrano-scalr
|
97
|
+
rubygems_version: 1.3.7
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Capistrano recipes for deploying to Scalr
|
101
|
+
test_files: []
|
102
|
+
|