Class: Rake::RemoteTask

Class | Rake::RemoteTask
In: | lib/rake_remote_task.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 default_env enhance env execute fetch host hosts_for new remote_task reset role roles rsync run set set_defaults sudo target_hosts task tasks

### Included Modules

Open4

### Classes and Modules

Class Rake::RemoteTask::Action

### External Aliases

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

### Attributes

options | [RW] | Options for execution of this task.
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

all_hosts()

Returns an Array with every host configured.

default_env()

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

env()

The vlad environment.

fetch(name, default = nil)

Fetches environment variable `name` from the environment using default `default`.

host(host_name, *roles)

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'

hosts_for(*roles)

Returns an Array of all hosts in `roles`.

new(task_name, app)

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

remote_task(name, options = {})

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

reset()

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

role(role_name, host, args = {})

Adds role `role_name` with `host` and `args` for that host.

roles()

The configured roles.

set(name, value = nil, &default_block)

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.

set_defaults()

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

task()

The Rake::RemoteTask executing in this Thread.

tasks()

The configured Rake::RemoteTasks.

### Public Instance methods

enhance(deps=nil, &block)

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

execute(args = nil)

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

rsync(local, remote)

Use rsync to send `local` to `remote` on target_host.

run(command)

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.

sudo(command)

Execute `command` under sudo using run.

target_hosts()

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]