wesabe / robot-army

Deploy scripting with Thor using remote Ruby execution

This URL has Read+Write access

Brian Donovan (author)
Wed Sep 23 13:28:03 -0700 2009
commit  0615c8d5b3845b789c60ebff3fe66de1bdb97071
tree    033f1fc99533b34cbfc8edfd34a42363123b74ec
parent  79c68ffb4579be972ab443f75049f993dbece63c
name age message
file .gitignore Mon Jun 23 18:39:40 -0700 2008 Yard is a bit of a moving target. [eventualbuddha]
file LICENSE Wed May 14 09:40:55 -0700 2008 Include a license and a Thorfile to package the... [eventualbuddha]
file README.markdown Thu Jun 19 16:17:33 -0700 2008 On-demand sudo password prompts. [eventualbuddha]
file Rakefile Wed May 14 09:47:46 -0700 2008 Add a dummy Rakefile that tells people to use t... [eventualbuddha]
file Thorfile Wed Sep 23 13:28:03 -0700 2009 Update to latest Thor and bump version. [Brian Donovan]
file VERSION Wed Sep 23 13:23:09 -0700 2009 Version bump to 0.1.7 [Brian Donovan]
directory examples/ Thu Jul 23 07:55:12 -0700 2009 Update to latest Thor (0.11.3). Version bump. [Brian Donovan]
directory lib/ Thu Jul 23 07:55:12 -0700 2009 Update to latest Thor (0.11.3). Version bump. [Brian Donovan]
file robot-army.gemspec Wed Sep 23 13:28:03 -0700 2009 Update to latest Thor and bump version. [Brian Donovan]
directory spec/ Wed Jul 22 12:25:20 -0700 2009 Delete cptemp directories on exit. The assumpt... [Brian Donovan]
README.markdown

Robot Army

Robot Army is deploy scripting which offers remote execution of Ruby in addition to the usual shell scripting offered by other deploy packages.

If you want to test this, be sure that the robot-army gem is installed on both the client and server machines. You should get an error if you try to execute it against a server with it installed.

Example

class AppServer < RobotArmy::TaskMaster
  host 'app1.prod.example.com'

  desc "time", "Get the time on the server (delta will be slightly off depending on SSH delay)"
  def time
    rtime = remote{ Time.now }
    ltime = Time.now

    say "The time on #{host} is #{rtime}, " +
        "#{(rtime-ltime).abs} seconds #{rtime < ltime ? 'behind' : 'ahead of'} localhost"
  end

  desc "deployed_revision", "Gets the deployed revision"
  def deployed_revision
    say "Checking deployed revision on #{host}"
    say "Deployed revision: #{remote{ File.read("/opt/app/current/REVISION") }}"
  end
end

Known Issues

  • Code executed in remote has no access to instance variables or globals
  • Probably doesn't work with Windows