capistrano-multiproject 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,19 +1,181 @@
1
- # capistrano-multiproject
1
+ capistrano-multiproject
2
+ =======================
2
3
 
3
- ## Description
4
+ Author: Olek Poplavsky
5
+
6
+
7
+ Introduction
8
+ ------------
4
9
 
5
10
  Capistrano extension that allows to deploy multiple projects from one location.
6
11
 
7
- Everybody knows/uses original multistage extension written by Jamis Buck. It works great while you have only one project/app to deploy.
8
- It is not quite enough if you have multiple projects to deploy (SOA would be one big use case here). Capistrano-multiproject solves this problem by allowing splitting up deploy.rb into multiple project-specific recipe files.
12
+ Everybody knows/uses original multistage extension written by Jamis Buck. It works great while you
13
+ have only one project/app to deploy. It is not quite enough if you have multiple projects to deploy
14
+ (SOA would be one big use case here). Capistrano-multiproject solves this problem by allowing
15
+ splitting up deploy.rb into multiple project-specific recipe files.
9
16
 
10
- ## Usage
17
+
18
+ Installation
19
+ ------------
11
20
 
12
21
  Install gem
13
22
 
14
23
  $ gem install capistrano-multiproject
15
24
 
16
25
 
26
+ Setup
27
+ -----
28
+
29
+ You are expected to create separate project, whole purpose of which is to deploy other projects.
30
+ That may be just a directory in your source repository, or a separate repository, it is up to you.
31
+
32
+ **Typical directory structure of 'deploy' project**
33
+
34
+ config/
35
+ deploy/
36
+ projects/
37
+ project1.rb
38
+ project2.rb
39
+ stages/
40
+ testing.rb
41
+ qa.rb
42
+ demo.rb
43
+ production.rb
44
+ deploy.rb
45
+ recipes/
46
+ recipe1.rb
47
+ recipe2.rb
48
+ Capfile
49
+ Gemfile
50
+
51
+
52
+ Usage
53
+ -----
54
+
55
+ If your run 'cap -T' you will see that only tasks that are loaded by default are projects, stages,
56
+ and strange '?' task. That last one is actually a replacement for '-T' option, that is customized
57
+ for the multiproject setup.
58
+
59
+ 'cap ?' outputs list of stages.
60
+
61
+ 'cap stage1 ?' outputs list of projects.
62
+
63
+ 'cap stage1 project1 ?' outputs list of capistrano tasks available in a given project.
64
+
65
+ 'cap stage1 project1 task1' executes capistrano task for some project in a context of given stage.
66
+
67
+
68
+ Configuration
69
+ -------------
70
+
71
+ Add to `Gemfile`
72
+
73
+ gem 'capistrano'
74
+ gem 'capistrano-multiproject'
75
+
17
76
  Add to `Capfile`
18
77
 
19
78
  require 'capistrano/multiproject'
79
+ load 'config/deploy'
80
+
81
+ Create file config/deploy.rb. Put you common settings/recipes there, those will be shared by all
82
+ projects. Settings like 'scm', 'repository', 'use_sudo', 'ssh_options' are good candidates to put
83
+ here.
84
+ Require common shared recipes like this:
85
+
86
+ load 'recipes/recipe1.rb'
87
+
88
+ Create directories deploy/projects and deploy/stages.
89
+
90
+ Stages directory contains .rb files that describe settings particular to specific stage. Usually all
91
+ that is done here is setting branch (or repository) and bunch of server roles.
92
+
93
+ Example of stage file config/deploy/stages/stage1.rb:
94
+
95
+ role :app, 'app1.foo.com', 'app2.foo.com'
96
+ role :redis, 'misc.foo.com'
97
+ role :shpinx, 'misc.foo.com'
98
+ role :db, 'masterdb.foo.com', :primary => true, :master => true
99
+ role :db, 'slavedb.foo.com', :no_release => true, :master => false
100
+ set :branch, 'master'
101
+
102
+ Projects directory contains .rb files that contains recipes specifit to particular project.
103
+
104
+ Example config/deploy/projects/foo.rb:
105
+
106
+ load 'recipes/recipe1.rb'
107
+
108
+ set :shared_children, %w(log pids)
109
+
110
+ namespace :deploy do
111
+ desc "Stops foo service"
112
+ task :stop do
113
+ run "#{sudo} /etc/init.d/foo stop"
114
+ end
115
+
116
+ desc "Starts foo service"
117
+ task :start do
118
+ run "#{sudo} /etc/init.d/foo start"
119
+ end
120
+
121
+ desc "Restarts foo service"
122
+ task :restart do
123
+ run "#{sudo} /etc/init.d/foo restart"
124
+ end
125
+ end
126
+
127
+ By default, only roles that are named the same as project file, are loaded (that is, for project
128
+ 'foo.rb', only role 'foo' will be loaded, roles 'db', 'redis' etc will not make it to capistrano.
129
+ When this needs to be customized, it is easy to do that my setting property project_roles like this:
130
+
131
+ set :project_roles, ['role1', 'role2']
132
+
133
+ In addition to roles defined in stage file, project's recipes have access to one special/synthetic 'any_server' role.
134
+ That role contains all the servers that were defined in the stage file, combined. It is very useful
135
+ to implement some administration recipes, like 'reboot all servers', 'update ubuntu software on all
136
+ servers', or 'run chef-client on all servers'.
137
+
138
+ Example config/deploy/projects/admin.rb:
139
+
140
+ set :project_roles, %w(any_server)
141
+ namespace :servers do
142
+ namespace :reboot do
143
+ desc "Reboot all servers"
144
+ task :all do
145
+ run "#{sudo} shutdown -r +1" # reboot in 1 minute
146
+ end
147
+ end
148
+ end
149
+
150
+
151
+ Compatibility
152
+ -------------
153
+
154
+ So far it was tested to work under ruby 1.9.
155
+
156
+ There is no good reason why it would not work with ruby 1.8, if you find problem with that, come
157
+ back to me and we will fix it together :)
158
+
159
+
160
+ License
161
+ -------
162
+
163
+ capistrano-multiproject is released under the [MIT][license] license.
164
+
165
+ [license]: http://www.opensource.org/licenses/MIT
166
+
167
+
168
+ Credits
169
+ -------
170
+
171
+ **Jamis Buck**
172
+
173
+ [capistrano-multistage][multistage] started it all
174
+
175
+ **Andriy Yanko**
176
+
177
+ [caphub][caphub] and [capistrano-multiconfig][multiconfig] were the inspiration for this project
178
+
179
+ [multistage]: http://weblog.jamisbuck.org/2007/7/23/capistrano-multistage
180
+ [caphub]: https://github.com/railsware/caphub
181
+ [multiconfig]: https://github.com/railsware/capistrano-multiconfig
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "capistrano-multiproject"
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
  s.authors = ["Olek Poplavsky"]
7
7
  s.email = ["olek@woodenbits.com"]
8
8
  s.homepage = "https://github.com/woodenbits/capistrano-multiproject"
@@ -2,9 +2,11 @@ Capistrano::Configuration.instance.load do
2
2
  namespace :multiproject do
3
3
  desc "[internal] Generate arteficial any_server role that enumerates all known servers"
4
4
  task :any_server_role do
5
- project_roles_sym = project_roles.map(&:to_sym)
6
- servers = roles.values.map(&:servers).flatten.sort.uniq.map(&:to_s)
7
- top.role :any_server, *servers, :no_release => true
5
+ project_roles_sym = project_roles.map { |o| o.to_sym }
6
+ servers = roles.values.map { |o| o.servers }.map { |o| o.to_s }.flatten.sort.uniq
7
+ # ruby 1.8 hates having hash after expanding array, while 1.9 is totally cool with that
8
+ # top.role(:any_server, *servers, { :no_release => true })
9
+ servers.each { |s| top.server s, :any_server, :no_release => true }
8
10
  end
9
11
  end
10
12
 
@@ -2,8 +2,8 @@ Capistrano::Configuration.instance.load do
2
2
  namespace :multiproject do
3
3
  desc "[internal] Filter roles to only those that are used by the current project"
4
4
  task :filter_roles do
5
- project_roles_sym = project_roles.map(&:to_sym)
6
- roles.select! { |k,v| project_roles_sym.include?(k) }
5
+ project_roles_sym = project_roles.map { |o| o.to_sym }
6
+ roles.delete_if { |k,v| !project_roles_sym.include?(k) }
7
7
  logger.info "Filtered roles down to '#{roles.keys.sort.join(', ')}'"
8
8
  if roles.empty? && project_roles == [project]
9
9
  abort "Define servers of role '#{project}' in stage '#{stage}' configuration, or specify project roles in project recipe (e.g. 'set :project_roles, [:foo, :bar]')"
metadata CHANGED
@@ -1,50 +1,39 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: capistrano-multiproject
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Olek Poplavsky
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-01-26 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: capistrano
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2152540700 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 43
29
- segments:
30
- - 2
31
- - 9
32
- - 0
20
+ - !ruby/object:Gem::Version
33
21
  version: 2.9.0
34
22
  type: :runtime
35
- version_requirements: *id001
36
- description: "\n\
37
- Everybody knows/uses original multistage extension written by Jamis Buck. It works great while you have only one project/app to deploy.\n\
38
- It is not quite enough if you have multiple projects to deploy (SOA would be one big use case here). Capistrano-multiproject solves this problem by allowing splitting up deploy.rb into multiple project-specific recipe files.\n "
39
- email:
23
+ prerelease: false
24
+ version_requirements: *2152540700
25
+ description: ! "\nEverybody knows/uses original multistage extension written by Jamis
26
+ Buck. It works great while you have only one project/app to deploy.\nIt is not quite
27
+ enough if you have multiple projects to deploy (SOA would be one big use case here).
28
+ Capistrano-multiproject solves this problem by allowing splitting up deploy.rb into
29
+ multiple project-specific recipe files.\n "
30
+ email:
40
31
  - olek@woodenbits.com
41
32
  executables: []
42
-
43
33
  extensions: []
44
-
45
- extra_rdoc_files:
34
+ extra_rdoc_files:
46
35
  - README.md
47
- files:
36
+ files:
48
37
  - capistrano-multiproject.gemspec
49
38
  - Gemfile
50
39
  - lib/capistrano/multiproject/configurations.rb
@@ -57,36 +46,27 @@ files:
57
46
  - README.md
58
47
  homepage: https://github.com/woodenbits/capistrano-multiproject
59
48
  licenses: []
60
-
61
49
  post_install_message:
62
- rdoc_options:
50
+ rdoc_options:
63
51
  - --charset=UTF-8
64
- require_paths:
52
+ require_paths:
65
53
  - lib
66
- required_ruby_version: !ruby/object:Gem::Requirement
54
+ required_ruby_version: !ruby/object:Gem::Requirement
67
55
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
75
- required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
61
  none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: 3
81
- segments:
82
- - 0
83
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
84
66
  requirements: []
85
-
86
67
  rubyforge_project:
87
- rubygems_version: 1.8.13
68
+ rubygems_version: 1.8.10
88
69
  signing_key:
89
70
  specification_version: 3
90
71
  summary: Capistrano extension that allows to deploy multiple projects from one location
91
72
  test_files: []
92
-