Class Rake::RemoteTask
In: lib/rake_remote_task.rb
lib/vlad_test_case.rb
Parent: Rake::Task

Rake::RemoteTask is a subclass of Rake::Task that adds remote_actions that execute in parallel on multiple hosts via ssh.

Methods

all_hosts   current_roles   default_env   defined_target_hosts?   enhance   env   execute   fetch   get   host   hosts_for   new   per_thread   popen4   put   remote_task   reset   role   roles   rsync   run   select   set   set_defaults   sudo   system   target_hosts   task   tasks  

Included Modules

Open4

Classes and Modules

Class Rake::RemoteTask::Action
Class Rake::RemoteTask::Status

Constants

Status = Struct.new :exitstatus

External Aliases

enhance -> original_enhance
  Add a local action to this task. This calls Rake::Task#enhance.

Attributes

action  [RW] 
commands  [RW] 
error  [RW] 
input  [RW] 
options  [RW]  Options for execution of this task.
output  [RW] 
remote_actions  [R]  An Array of Actions this host will perform during execution. Use enhance to add new actions to a task.
target_host  [RW]  The host this task is running on during execution.

Public Class methods

Returns an Array with every host configured.

The default environment values. Used for resetting (mostly for tests).

The vlad environment.

Fetches environment variable name from the environment using default default.

Add host host_name that belongs to roles. Extra arguments may be specified for the host as a hash as the last argument.

host is the inversion of role:

  host 'db1.example.com', :db, :master_db

Is equivalent to:

  role :db, 'db1.example.com'
  role :master_db, 'db1.example.com'

Returns an Array of all hosts in roles.

Create a new task named task_name attached to Rake::Application app.

Adds a remote task named name with options options that will execute block.

Resets vlad, restoring all roles, tasks and environment variables to the defaults.

Adds role role_name with host and args for that host. TODO: merge: Declare a role and assign a remote host to it. Equivalent to the host method; provided for capistrano compatibility.

The configured roles.

Set environment variable name to value or default_block.

If default_block is defined, the block will be executed the first time the variable is fetched, and the value will be used for every subsequent fetch.

Sets all the default values. Should only be called once. Use reset if you need to restore values.

The Rake::RemoteTask executing in this Thread.

The configured Rake::RemoteTasks.

Public Instance methods

Similar to target_hosts, but returns true if user defined any hosts, even an empty list.

Add remote action block to this task with dependencies deps. See Rake::Task#enhance.

Execute this action. Local actions will be performed first, then remote actions will be performed in parallel on each host configured for this RemoteTask.

Pull files from the remote host using rsync to local_dir. TODO: what if role has multiple hosts & the files overlap? subdirs?

Copy a (usually generated) file to remote_path. Contents of block are copied to remote_path and you may specify an optional base_name for the tempfile (aids in debugging).

Execute rsync with args. Tacks on pre-specified rsync_cmd and rsync_flags.

Favor get and put for most tasks. Old-style direct use where the target_host was implicit is now deprecated.

Use ssh to execute command on target_host. If command uses sudo, the sudo password will be prompted for then saved for subsequent sudo commands.

Execute command under sudo using run.

The hosts this task will execute on. The hosts are determined from the role this task belongs to.

The target hosts may be overridden by providing a comma-separated list of commands to the HOSTS environment variable:

  rake my_task HOSTS=app1.example.com,app2.example.com

[Validate]