lib/capissh/invocation.rb
# Execute the given command on all servers that are the target of the
# current task. If a block is given, it is invoked for all output
# generated by the command, and should accept three parameters: the SSH
# channel (which may be used to send data back to the remote process),
# the stream identifier (<tt>:err</tt> for stderr, and <tt>:out</tt> for
# stdout), and the data that was received.
#
# The +options+ hash may include any of the following keys:
#
# * :on_no_matching_servers - if :continue, will continue to execute tasks if
#   no matching servers are found for the host criteria. The default is to raise
#   a NoMatchingServersError exception.
# * :max_hosts - specifies the maximum number of hosts that should be selected
#   at a time. If this value is less than the number of hosts that are selected
#   to run, then the hosts will be run in groups of max_hosts. The default is nil,
#   which indicates that there is no maximum host limit. Please note this does not
#   limit the number of SSH channels that can be open, only the number of hosts upon
#   which this will be called.
# * :shell - says which shell should be used to invoke commands. This
#   defaults to "sh". Setting this to false causes Capissh to invoke
#   the commands directly, without wrapping them in a shell invocation.
# * :data - if not nil (the default), this should be a string that will
#   be passed to the command's stdin stream.
# * :pty - if true, a pseudo-tty will be allocated for each command. The
#   default is false. Note that there are benefits and drawbacks both ways.
#   Empirically, it appears that if a pty is allocated, the SSH server daemon
#   will _not_ read user shell start-up scripts (e.g. bashrc, etc.). However,
#   if a pty is _not_ allocated, some commands will refuse to run in
#   interactive mode and will not prompt for (e.g.) passwords.
# * :env - a hash of environment variable mappings that should be made
#   available to the command. The keys should be environment variable names,
#   and the values should be their corresponding values. The default is
#   empty, but may be modified by changing the +default_environment+
#   Capissh variable.
# * :eof - if true, the standard input stream will be closed after sending
#   any data specified in the :data option. If false, the input stream is
#   left open. The default is to close the input stream only if no block is
#   passed.
#
# Note that if you set these keys in the +default_run_options+ Capissh
# variable, they will apply for all invocations of #run, #invoke_command,
# and #parallel.
Execute the given command on all servers that are the target of the
current task. If a block is given, it is invoked for all output
generated by the command, and should accept three parameters: the SSH
channel (which may be used to send data back to the remote process),
the stream identifier (:err for stderr, and :out for
stdout), and the data that was received.

The +options+ hash may include any of the following keys.

:on_no_matching_servers - if :continue, will continue to execute tasks if
no matching servers are found for the host criteria. The default is to raise
a NoMatchingServersError exception.
:max_hosts - specifies the maximum number of hosts that should be selected
at a time. If this value is less than the number of hosts that are selected
to run, then the hosts will be run in groups of max_hosts. The default is nil,
which indicates that there is no maximum host limit. Please note this does not
limit the number of SSH channels that can be open, only the number of hosts upon
which this will be called.
:shell - says which shell should be used to invoke commands. This
defaults to "sh". Setting this to false causes Capissh to invoke
the commands directly, without wrapping them in a shell invocation.
:data - if not nil (the default), this should be a string that will
be passed to the command's stdin stream.
:pty - if true, a pseudo-tty will be allocated for each command. The
default is false. Note that there are benefits and drawbacks both ways.
Empirically, it appears that if a pty is allocated, the SSH server daemon
will _not_ read user shell start-up scripts . However,
if a pty is _not_ allocated, some commands will refuse to run in
interactive mode and will not prompt for  passwords.
:env - a hash of environment variable mappings that should be made
available to the command. The keys should be environment variable names,
and the values should be their corresponding values. The default is
empty, but may be modified by changing the +default_environment+
Capissh variable.
:eof - if true, the standard input stream will be closed after sending
any data specified in the :data option. If false, the input stream is
left open. The default is to close the input stream only if no block is
passed.

Note that if you set these keys in the +default_run_options+ Capissh
variable, they will apply for all invocations of #run, #invoke_command,
and #parallel.
Execute the given command on all servers that are the target of the current task . If a block is given it is invoked for all output generated by the command and should accept three parameters : the SSH channel ( which may be used to send data back to the remote process ) the stream identifier ( : err for stderr and : out for stdout ) and the data that was received . The + options + hash may include any of the following keys . : on_no_matching_servers - if : continue will continue to execute tasks if no matching servers are found for the host criteria . The default is to raise a NoMatchingServersError exception . : max_hosts - specifies the maximum number of hosts that should be selected at a time . If this value is less than the number of hosts that are selected to run then the hosts will be run in groups of max_hosts . The default is nil which indicates that there is no maximum host limit . Please note this does not limit the number of SSH channels that can be open only the number of hosts upon which this will be called . : shell - says which shell should be used to invoke commands . This defaults to " sh " . Setting this to false causes Capissh to invoke the commands directly without wrapping them in a shell invocation . : data - if not nil ( the default ) this should be a string that will be passed to the command ' s stdin stream . : pty - if true a pseudo - tty will be allocated for each command . The default is false . Note that there are benefits and drawbacks both ways . Empirically it appears that if a pty is allocated the SSH server daemon will _not_ read user shell start - up scripts . However if a pty is _not_ allocated some commands will refuse to run in interactive mode and will not prompt for passwords . : env - a hash of environment variable mappings that should be made available to the command . The keys should be environment variable names and the values should be their corresponding values . The default is empty but may be modified by changing the + default_environment + Capissh variable . : eof - if true the standard input stream will be closed after sending any data specified in the : data option . If false the input stream is left open . The default is to close the input stream only if no block is passed . Note that if you set these keys in the + default_run_options + Capissh variable they will apply for all invocations of #run #invoke_command and #parallel .
def run(servers, cmd, options={}, &block)
      if options[:eof].nil? && !cmd.include?(sudo_command)
        options = options.merge(:eof => !block_given?)
      end
      block ||= Command.default_io_callback
      tree = CommandTree.twig(configuration, cmd, options, &block)
      run_tree(servers, tree, options)
    end
def run ( servers , cmd , options = { } , & block ) if options [ :eof ] . nil? && ! cmd . include? ( sudo_command ) options = options . merge ( :eof => ! block_given? ) end block ||= Command . default_io_callback tree = CommandTree . twig ( configuration , cmd , options , & block ) run_tree ( servers , tree , options ) end
Execute the given command on all servers that are the target of the
current task.
Execute the given command on all servers that are the target of the current task .
servers
cmd
options
block