class Sprinkle::Actors::Capistrano
The Capistrano
actor uses Capistrano
to define your roles and deliver commands to your remote servers. You'll need the capistrano gem installed.
The only configuration option is to specify a recipe.
deployment do delivery :capistrano do recipe 'deploy' recipe 'more' end end
Recipes is given a list of files which capistrano will include and load. These recipes are mainly to set variables such as :user, :password, and to set the app domain which will be sprinkled.
Public Instance Methods
Defines a recipe file which will be included by capistrano. Use these recipe files to set capistrano specific configurations. Default recipe included is “deploy.” But if any other recipe is specified, it will include that instead. Multiple recipes may be specified through multiple recipes calls, an example:
deployment do delivery :capistrano do recipe 'deploy' recipes 'magic_beans', 'normal_beans' end end
# File lib/sprinkle/actors/capistrano.rb, line 71 def recipe(scripts) @loaded_recipes ||= [] Array(scripts).each do |script| @config.load script @loaded_recipes << script end end
Private Instance Methods
REVISIT: can we set the description somehow?
# File lib/sprinkle/actors/capistrano.rb, line 150 def define_task(name, roles, &block) @config.task task_sym(name), :roles => roles, &block end
# File lib/sprinkle/actors/capistrano.rb, line 136 def raise_error(e) details={:command => @log_recorder.command, :code => "??", :message => e.message, :hosts => e.hosts, :error => @log_recorder.err, :stdout => @log_recorder.out} raise Sprinkle::Errors::RemoteCommandFailure.new(@installer, details, e) end
rip out any double sudos from the beginning of the command
# File lib/sprinkle/actors/capistrano.rb, line 126 def rewrite_command(cmd) return cmd if cmd.is_a?(Symbol) via = @config.fetch(:run_method) if via == :sudo and cmd =~ /^#{sudo_command}/ cmd.gsub(/^#{sudo_command}\s?/,"") else cmd end end
# File lib/sprinkle/actors/capistrano.rb, line 154 def run(task) @config.send task_sym(task) end
# File lib/sprinkle/actors/capistrano.rb, line 144 def run_task(task, opts={}) run(task) true end
# File lib/sprinkle/actors/capistrano.rb, line 158 def task_sym(name) "install_#{name.to_task_name}".to_sym end