lib/sshkit/runners/sequential.rb in sshkit-1.10.0 vs lib/sshkit/runners/sequential.rb in sshkit-1.11.0

- old
+ new

@@ -1,11 +1,17 @@ module SSHKit module Runner class Sequential < Abstract - attr_writer :wait_interval + attr_accessor :wait_interval + + def initialize(hosts, options = nil, &block) + super(hosts, options, &block) + @wait_interval = @options[:wait] || 2 + end + def execute last_host = hosts.pop hosts.each do |host| run_backend(host, &block) @@ -14,20 +20,18 @@ unless last_host.nil? run_backend(last_host, &block) end end + private def run_backend(host, &block) backend(host, &block).run rescue StandardError => e e2 = ExecuteError.new e raise e2, "Exception while executing #{host.user ? "as #{host.user}@" : "on host "}#{host}: #{e.message}" end - def wait_interval - @wait_interval || options[:wait] || 2 - end end end end