lib/remote_run/configuration.rb in remote_run-0.1.4 vs lib/remote_run/configuration.rb in remote_run-0.1.5
- old
+ new
@@ -1,22 +1,26 @@
module RemoteRun
class Configuration
- attr_accessor :remote_path, :local_path, :login_as, :exclude, :temp_path, :quiet, :before_task, :after_task, :before_run, :after_run, :around_task, :around_run
+ attr_accessor :remote_path, :local_path, :login_as, :exclude, :temp_path, :quiet, :before_task, :after_task, :before_run, :after_run, :around_task, :around_run,
+ :known_hosts, :ssh_options, :rsync_options
attr_reader :local_hostname, :identifier, :start_time
attr_reader :host_manager, :task_manager
def initialize
@task_manager = TaskManager.new
@host_manager = HostManager.new
@local_path = Dir.getwd
- @login_as = `whoami`.strip
+ @login_as = ENV["USER"]
@remote_path = "/tmp/remote"
@exclude = []
@temp_path = "/tmp/remote"
@quiet = false
@start_time = Time.now
+ @known_hosts = File.expand_path("#{ENV['HOME']}/.ssh/known_hosts")
+ @ssh_options = "-o NoHostAuthenticationForLocalhost=yes -o UserKnownHostsFile=#{known_hosts} -o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=no -o ConnectTimeout=3 -4 "
+ @rsync_options = "--delete --rsh='ssh #{ssh_options}' --timeout=60 -a"
# used in the runner
@identifier = `echo $RANDOM`.strip
@local_hostname = `hostname`.strip
@@ -25,11 +29,11 @@
@around_run = Proc.new {|&block| block.call }
@before_task = Proc.new{}
@after_task = Proc.new{}
@around_task = Proc.new {|&block| block.call }
$runner = self
- yield self
+ yield self if block_given?
end
def hosts
@host_manager.hosts
end
@@ -38,10 +42,10 @@
@task_manager.tasks
end
def hosts=(hostnames)
hostnames.each do |hostname|
- @host_manager.add(Host.new(hostname))
+ @host_manager.add(Host.new(hostname, self))
end
end
def tasks=(shell_commands)
shell_commands.each do |shell_command|