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 :password, "hello-flippy"
0
+# set :gateway, "gateway.example.com"
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
-# The deploy_to path is optional, defaulting to "/u/apps/#{application}".
0
-set :deploy_to, "/path/to/app/root"
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
-# By default, the source control module (scm) is set to "subversion". You can
0
-# set it to any supported scm:
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
-set :gateway, "gateway.example.com"
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
-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
-# 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
-An imaginary backup task. (Execute the 'show_tasks' task to display all
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
-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
- run "mysqldump -u theuser -p thedatabase > /tmp/dump.sql" do |ch, stream, out|
0
- ch.send_data "thepassword\n" if out =~ /^Enter password:/
0
-# Tasks may take advantage of several different helper methods to interact
0
-# with the remote server(s). These are:
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
-# * sudo(command, options={}, &block): same as run, but it executes the command
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
-# * 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
-desc "Demonstrates the various helper methods available to recipes."
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
- 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
-# 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
-desc "A task demonstrating the use of transactions."
0
+task :sample_task, :roles => :app do
Comments
No one has commented yet.