public
Fork of jamis/capistrano
Description: Remote multi-server automation tool
Homepage: http://www.capify.org
Clone URL: git://github.com/rmm5t/capistrano.git
Search Repo:
THANKS file is not applicable anymore. Bring various other files 
up-to-date with reality.


git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6326 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jamis (author)
Sun Mar 04 14:25:51 -0800 2007
commit  414da791d23ee9184d473533843a41919e059db0
tree    c5bc8d7fa38da582d0bd94fc951ac0b1da53dd9b
parent  c0e2ee20f9ed0d7cb3a5466d1ebcf55dd41891b6
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-Copyright (c) 2005,2006 Jamis Buck
0
+Copyright (c) 2005-2007 Jamis Buck <jamis@37signals.com>
0
 
0
 Permission is hereby granted, free of charge, to any person obtaining
0
 a copy of this software and associated documentation files (the
0
...
2
3
4
5
 
6
7
8
9
 
 
 
 
 
 
 
10
11
12
13
 
14
15
16
17
18
 
 
19
20
 
21
22
23
24
25
26
27
28
29
 
 
30
31
32
33
 
34
35
 
...
2
3
4
 
5
6
7
8
 
9
10
11
12
13
14
15
16
17
18
 
19
20
 
 
 
 
21
22
23
 
24
25
26
27
 
 
28
29
 
 
30
31
32
33
34
 
35
36
 
37
0
@@ -2,34 +2,36 @@
0
 
0
 Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH. It uses a simple DSL (borrowed in part from Rake, http://rake.rubyforge.org/) that allows you to define _tasks_, which may be applied to machines in certain roles. It also supports tunneling connections via some gateway machine to allow operations to be performed behind VPN's and firewalls.
0
 
0
-Capistrano was originally designed to simplify and automate deployment of web applications to distributed environments, and so it comes with many tasks predefined for that ("update_code" and "deploy", for instance).
0
+Capistrano was originally designed to simplify and automate deployment of web applications to distributed environments, and originally came bundled with a set of tasks designed for deploying Rails applications. The deployment tasks are now (as of Capistrano 2.0) distributed as a separate package: capistrano-deploy.
0
 
0
 == Dependencies
0
 
0
-Capistrano depends upon the Net::SSH library by Jamis Buck (http://net-ssh.rubyforge.org). Net::SSH itself depends on the Needle library (http://needle.rubyforge.org), also by Jamis Buck.
0
+* Net::SSH and Net::SFTP (http://net-ssh.rubyforge.org)
0
+* Needle (via Net::SSH)
0
+* HighLine (http://highline.rubyforge.org)
0
+
0
+If you want to run the tests, you'll also need to have the following dependencies installed:
0
+
0
+* Mocha (http://mocha.rubyforge.org)
0
 
0
 == Assumptions
0
 
0
-In keeping with Rails' "convention over configuration", Capistrano makes several assumptions about how you will use it (most, if not all, of which may be explicitly overridden):
0
+Capistrano is "opinionated software", which means it has very firm ideas about how things ought to be done, and tries to force those ideas on you. Some of the assumptions behind these opinions are:
0
 
0
-* You are writing web applications and want to use Capistrano to deploy them.
0
-* You are using Ruby on Rails (http://www.rubyonrails.com) to build your apps.
0
-* You are using Subversion (http://subversion.tigris.org/) to manage your source code.
0
-* You are running your apps using FastCGI, together with Rails' spinner/reaper utilities.
0
+* You are using SSH to access the remote servers.
0
+* You either have the same password to all target machines, or you have public keys in place to allow passwordless access to them.
0
 
0
-As with the rest of Rails, if you can abide by these assumptions, you can use Capistrano "out of the box". If any of these assumptions do not hold, you'll need to make some adjustments to your deployment recipe files.
0
+Do not expect these assumptions to change.
0
 
0
 == Usage
0
 
0
-More documentation is always pending, but you'll want to see the user manual for detailed usage instructions. (The manual is online at http://manuals.rubyonrails.org/read/book/17).
0
-
0
 In general, you'll use Capistrano as follows:
0
 
0
-* Create a deployment recipe ("deploy.rb") for your application. You can use the sample recipe in examples/sample.rb as a starting point.
0
-* Use the +cap+ script to execute your recipe (see below).
0
+* Create a recipe file ("capfile" or "Capfile").
0
+* Use the +cap+ script to execute your recipe.
0
 
0
 Use the +cap+ script as follows:
0
 
0
- cap -vvv someaction
0
+ cap sometask
0
 
0
-By default, the script will look for a file called one of <tt>config/deploy</tt>, <tt>config/deploy.rb</tt>, <tt>capistrano</tt>, or <tt>capistrano.rb</tt>. You can the <tt>-v</tt> switch multiple times (as shown) to increase the verbosity of the output. The +someaction+ text indicates which action to execute.
0
+By default, the script will look for a file called one of +capfile+ or +Capfile+. The +someaction+ text indicates which task to execute. You can do "cap -h" to see all the available options and "cap -T" to see all the available tasks.
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
0
   s.version = PKG_VERSION
0
   s.platform = Gem::Platform::RUBY
0
   s.summary = <<-DESC.strip.gsub(/\n\s+/, " ")
0
- Capistrano is a framework and utility for executing commands in parallel
0
+ Capistrano is a utility and framework for executing commands in parallel
0
     on multiple remote machines, via SSH.
0
   DESC
0
 
...
1
2
3
4
 
 
 
5
6
7
 
 
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
 
 
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
 
113
...
 
 
 
 
1
2
3
4
 
 
5
6
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
9
10
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
13
14
0
@@ -1,113 +1,14 @@
0
-# You must always specify the application and repository for every recipe. The
0
-# repository must be the URL of the repository you want this recipe to
0
-# correspond to. The deploy_to path must be the path on each machine that will
0
-# form the root of the application path.
0
+# set :user, "flippy"
0
+# set :password, "hello-flippy"
0
+# set :gateway, "gateway.example.com"
0
 
0
-set :application, "sample"
0
-set :repository, "http://svn.example.com/#{application}/trunk"
0
+role :web, "web1.example.com"
0
+role :app, "app1.example.com", "app2.example.com"
0
 
0
-# The deploy_to path is optional, defaulting to "/u/apps/#{application}".
0
-
0
-set :deploy_to, "/path/to/app/root"
0
-
0
-# The user value is optional, defaulting to user-name of the current user. This
0
-# is the user name that will be used when logging into the deployment boxes.
0
-
0
-set :user, "flippy"
0
-
0
-# By default, the source control module (scm) is set to "subversion". You can
0
-# set it to any supported scm:
0
-
0
-set :scm, :subversion
0
-
0
-# gateway is optional, but allows you to specify the address of a computer that
0
-# will be used to tunnel other requests through, such as when your machines are
0
-# all behind a VPN or something
0
-
0
-set :gateway, "gateway.example.com"
0
-
0
-# You can define any number of roles, each of which contains any number of
0
-# machines. Roles might include such things as :web, or :app, or :db, defining
0
-# what the purpose of each machine is. You can also specify options that can
0
-# be used to single out a specific subset of boxes in a particular role, like
0
-# :primary => true.
0
-
0
-role :web, "www01.example.com", "www02.example.com"
0
-role :app, "app01.example.com", "app02.example.com", "app03.example.com"
0
-role :db, "db01.example.com", :primary => true
0
-role :db, "db02.example.com", "db03.example.com"
0
-
0
-# Define tasks that run on all (or only some) of the machines. You can specify
0
-# a role (or set of roles) that each task should be executed on. You can also
0
-# narrow the set of servers to a subset of a role by specifying options, which
0
-# must match the options given for the servers to select (like :primary => true)
0
-
0
-desc <<DESC
0
-An imaginary backup task. (Execute the 'show_tasks' task to display all
0
-available tasks.)
0
+desc <<-DESC
0
+This is a sample task. It is only intended to be used as a demonstration of \
0
+how you can define your own tasks.
0
 DESC
0
-
0
-task :backup, :roles => :db, :only => { :primary => true } do
0
- # the on_rollback handler is only executed if this task is executed within
0
- # a transaction (see below), AND it or a subsequent task fails.
0
- on_rollback { delete "/tmp/dump.sql" }
0
-
0
- run "mysqldump -u theuser -p thedatabase > /tmp/dump.sql" do |ch, stream, out|
0
- ch.send_data "thepassword\n" if out =~ /^Enter password:/
0
- end
0
-end
0
-
0
-# Tasks may take advantage of several different helper methods to interact
0
-# with the remote server(s). These are:
0
-#
0
-# * run(command, options={}, &block): execute the given command on all servers
0
-# associated with the current task, in parallel. The block, if given, should
0
-# accept three parameters: the communication channel, a symbol identifying the
0
-# type of stream (:err or :out), and the data. The block is invoked for all
0
-# output from the command, allowing you to inspect output and act
0
-# accordingly.
0
-# * sudo(command, options={}, &block): same as run, but it executes the command
0
-# via sudo.
0
-# * delete(path, options={}): deletes the given file or directory from all
0
-# associated servers. If :recursive => true is given in the options, the
0
-# delete uses "rm -rf" instead of "rm -f".
0
-# * put(buffer, path, options={}): creates or overwrites a file at "path" on
0
-# all associated servers, populating it with the contents of "buffer". You
0
-# can specify :mode as an integer value, which will be used to set the mode
0
-# on the file.
0
-# * render(template, options={}) or render(options={}): renders the given
0
-# template and returns a string. Alternatively, if the :template key is given,
0
-# it will be treated as the contents of the template to render. Any other keys
0
-# are treated as local variables, which are made available to the (ERb)
0
-# template.
0
-
0
-desc "Demonstrates the various helper methods available to recipes."
0
-task :helper_demo do
0
- # "setup" is a standard task which sets up the directory structure on the
0
- # remote servers. It is a good idea to run the "setup" task at least once
0
- # at the beginning of your app's lifetime (it is non-destructive).
0
- setup
0
-
0
- buffer = render("maintenance.rhtml", :deadline => ENV['UNTIL'])
0
- put buffer, "#{shared_path}/system/maintenance.html", :mode => 0644
0
- sudo "killall -USR1 dispatch.fcgi"
0
- run "#{release_path}/script/spin"
0
- delete "#{shared_path}/system/maintenance.html"
0
-end
0
-
0
-# You can use "transaction" to indicate that if any of the tasks within it fail,
0
-# all should be rolled back (for each task that specifies an on_rollback
0
-# handler).
0
-
0
-desc "A task demonstrating the use of transactions."
0
-task :long_deploy do
0
- transaction do
0
- update_code
0
- disable_web
0
- symlink
0
- migrate
0
- end
0
-
0
- restart
0
- enable_web
0
+task :sample_task, :roles => :app do
0
+ run "ls -l"
0
 end

Comments

    No one has commented yet.