aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/remote
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-11-27 01:40:01 -0800
committerelijah <elijah@riseup.net>2012-11-27 01:40:01 -0800
commitb5bf2fe3874f9ce97b36dc37b17ce66270260f03 (patch)
tree7af8ccce2a3862545f04d91a60fcd8f3104e1342 /lib/leap_cli/remote
parent051675c61937f184c555bac3af07be182f0c6acd (diff)
downloadleap_cli-b5bf2fe3874f9ce97b36dc37b17ce66270260f03.tar.gz
leap_cli-b5bf2fe3874f9ce97b36dc37b17ce66270260f03.tar.bz2
improved logging all around.
Diffstat (limited to 'lib/leap_cli/remote')
-rw-r--r--lib/leap_cli/remote/plugin.rb35
-rw-r--r--lib/leap_cli/remote/tasks.rb18
2 files changed, 43 insertions, 10 deletions
diff --git a/lib/leap_cli/remote/plugin.rb b/lib/leap_cli/remote/plugin.rb
index 6b59727..a69cca4 100644
--- a/lib/leap_cli/remote/plugin.rb
+++ b/lib/leap_cli/remote/plugin.rb
@@ -4,6 +4,10 @@
module LeapCli; module Remote; module Plugin
+ def log(*args, &block)
+ LeapCli::Util::log(*args, &block)
+ end
+
def mkdir(dir)
run "mkdir -p #{dir}"
end
@@ -20,8 +24,8 @@ module LeapCli; module Remote; module Plugin
servers = SupplyDrop::Util.optionally_async(find_servers, puppet_parallel_rsync)
# rsync to each server
- failed_servers = servers.map do |server|
-
+ failed_servers = []
+ servers.each do |server|
# build rsync command
paths = yield server
remote_user = server.user || fetch(:user, ENV['USER'])
@@ -33,11 +37,32 @@ module LeapCli; module Remote; module Plugin
# run command
logger.debug rsync_cmd
- server.host unless system rsync_cmd
-
- end.compact
+ ok = system(rsync_cmd)
+ if ok
+ logger.log 1, "rsync #{paths[:source]} #{paths[:dest]}", server.host, :color => :green
+ else
+ failed_servers << server.host
+ end
+ end
raise "rsync failed on #{failed_servers.join(',')}" if failed_servers.any?
end
+ #def logrun(cmd)
+ # @streamer ||= LeapCli::Remote::LogStreamer.new
+ # run cmd do |channel, stream, data|
+ # @streamer.collect_output(channel[:host], data)
+ # end
+ #end
+
+# return_code = nil
+# run "something; echo return code: $?" do |channel, stream, data|
+# if data =~ /return code: (\d+)/
+# return_code = $1.to_i
+# else
+# Capistrano::Configuration.default_io_proc.call(channel, stream, data)
+# end
+# end
+# puts "finished with return code: #{return_code}"
+
end; end; end \ No newline at end of file
diff --git a/lib/leap_cli/remote/tasks.rb b/lib/leap_cli/remote/tasks.rb
index 6bfffb2..4a29517 100644
--- a/lib/leap_cli/remote/tasks.rb
+++ b/lib/leap_cli/remote/tasks.rb
@@ -8,15 +8,21 @@ require 'supply_drop'
MAX_HOSTS = 10
task :install_authorized_keys, :max_hosts => MAX_HOSTS do
- run 'mkdir -p /root/.ssh && chmod 700 /root/.ssh'
- upload LeapCli::Path.named_path(:authorized_keys), '/root/.ssh/authorized_keys', :mode => '600'
+ leap.log :updating, "authorized_keys" do
+ run 'mkdir -p /root/.ssh && chmod 700 /root/.ssh'
+ upload LeapCli::Path.named_path(:authorized_keys), '/root/.ssh/authorized_keys', :mode => '600'
+ end
end
task :install_prerequisites, :max_hosts => MAX_HOSTS do
packages = "puppet ruby-hiera-puppet rsync lsb-release"
run "mkdir -p #{puppet_destination}"
- run "apt-get update"
- run "DEBIAN_FRONTEND=noninteractive apt-get -q -y -o DPkg::Options::=--force-confold install #{packages}"
+ leap.log :updating, "package list" do
+ run "apt-get update"
+ end
+ leap.log :installing, "required packages" do
+ run "DEBIAN_FRONTEND=noninteractive apt-get -q -y -o DPkg::Options::=--force-confold install #{packages}"
+ end
end
#task :update_platform, :max_hosts => MAX_HOSTS do
@@ -29,5 +35,7 @@ end
task :apply_puppet, :max_hosts => MAX_HOSTS do
raise "now such directory #{puppet_source}" unless File.directory?(puppet_source)
- puppet.apply
+ leap.log :applying, "puppet" do
+ puppet.apply
+ end
end