Class: Wordmove::Actions::Ssh::RunRemoteCommand

Inherits:
Object
  • Object
show all
Extended by:
LightService::Action
Includes:
Helpers
Defined in:
lib/wordmove/actions/ssh/run_remote_command.rb

Overview

Note:

The remote server is already configured inside the Photocopier object

Note:

This action is not meant to be organized, but as a standalone one.

Run a command on a remote host using Photocopier

Class Method Summary collapse

Class Method Details

.executeLightService::Context

Returns Action’s context.

Parameters:

  • photocopier (Photocopier)
  • logger (Wordmove::Logger)
  • cli_options (Hash)

    The hash of command line options

  • command (String)

    the command to run

Returns:

  • (LightService::Context)

    Action’s context



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/wordmove/actions/ssh/run_remote_command.rb', line 24

executed do |context|
  context.logger.task_step false, context.command

  next context if simulate?(cli_options: context.cli_options)

  _stdout, stderr, exit_code = context.photocopier.exec!(context.command)

  next context if exit_code.zero?

  context.fail! "Error code #{exit_code} returned by command " \
                "#{context.command}: #{stderr}"
end