aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/remote/rsync_plugin.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-04-01 00:04:54 -0700
committerelijah <elijah@riseup.net>2013-04-01 00:04:54 -0700
commitb9a20186350a0315ee7159f2df2b55a47e9f90a4 (patch)
tree845b08feaa723a00d6dc7da26be68471fc4c7e1e /lib/leap_cli/remote/rsync_plugin.rb
parentc3f78c9df38f6e4dec94737863dcfcc1f4e60e96 (diff)
downloadleap_cli-b9a20186350a0315ee7159f2df2b55a47e9f90a4.tar.gz
leap_cli-b9a20186350a0315ee7159f2df2b55a47e9f90a4.tar.bz2
remove supply_drop, add support for puppet_command.
Diffstat (limited to 'lib/leap_cli/remote/rsync_plugin.rb')
-rw-r--r--lib/leap_cli/remote/rsync_plugin.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/leap_cli/remote/rsync_plugin.rb b/lib/leap_cli/remote/rsync_plugin.rb
new file mode 100644
index 0000000..2c89f26
--- /dev/null
+++ b/lib/leap_cli/remote/rsync_plugin.rb
@@ -0,0 +1,35 @@
+#
+# these methods are made available in capistrano tasks as 'rsync.method_name'
+# (see RemoteCommand::new_capistrano)
+#
+
+require 'rsync_command'
+
+module LeapCli; module Remote; module RsyncPlugin
+
+ #
+ # takes a block, yielded a server, that should return a hash with various rsync options.
+ # supported options include:
+ #
+ # {:source => '', :dest => '', :flags => '', :includes => [], :excludes => []}
+ #
+ def update
+ rsync = RsyncCommand.new(:logger => logger, :flags => '-a')
+ rsync.asynchronously(find_servers) do |server|
+ options = yield server
+ next unless options
+ remote_user = server.user || fetch(:user, ENV['USER'])
+ src = options[:source]
+ dest = {:user => remote_user, :host => server.host, :path => options[:dest]}
+ options[:ssh] = ssh_options.merge(server.options[:ssh_options]||{})
+ options[:chdir] ||= Path.provider
+ rsync.exec(src, dest, options)
+ end
+ if rsync.failed?
+ LeapCli::Util.bail! do
+ LeapCli::Util.log :failed, "to rsync to #{rsync.failures.map{|f|f[:dest][:host]}.join(' ')}"
+ end
+ end
+ end
+
+end; end; end