aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/remote
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-01-13 20:27:29 -0800
committerelijah <elijah@riseup.net>2013-01-13 20:27:29 -0800
commitba301b0c8d77ae2f455d3a2d736968c981b8c757 (patch)
treefac1c2f483732d158f106d8ad7917bfc7e07c239 /lib/leap_cli/remote
parentbea336480bf90f7c24737809e27b0bd224f42233 (diff)
downloadleap_cli-ba301b0c8d77ae2f455d3a2d736968c981b8c757.tar.gz
leap_cli-ba301b0c8d77ae2f455d3a2d736968c981b8c757.tar.bz2
added ability to sync support files along with hiera.yml. this way, files don't need to be embedded in hiera.yml. this is especially useful for binary files.
Diffstat (limited to 'lib/leap_cli/remote')
-rw-r--r--lib/leap_cli/remote/plugin.rb24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/leap_cli/remote/plugin.rb b/lib/leap_cli/remote/plugin.rb
index 803ebf9..213c981 100644
--- a/lib/leap_cli/remote/plugin.rb
+++ b/lib/leap_cli/remote/plugin.rb
@@ -57,22 +57,28 @@ module LeapCli; module Remote; module Plugin
# rsync to each server
failed_servers = []
servers.each do |server|
+ options = yield server
+ next unless options
+
# build rsync command
- paths = yield server
remote_user = server.user || fetch(:user, ENV['USER'])
+ rsync_options = {
+ :flags => options[:flags],
+ :includes => options[:includes],
+ :excludes => options[:excludes],
+ :ssh => ssh_options.merge(server.options[:ssh_options]||{})
+ }
rsync_cmd = SupplyDrop::Rsync.command(
- paths[:source],
- SupplyDrop::Rsync.remote_address(remote_user, server.host, paths[:dest]),
- {:ssh => ssh_options.merge(server.options[:ssh_options]||{})}
+ options[:source],
+ SupplyDrop::Rsync.remote_address(remote_user, server.host, options[:dest]),
+ rsync_options
)
# run command
logger.debug rsync_cmd
- ok = system(rsync_cmd)
- if ok
- logger.log 1, "rsync #{paths[:source]} #{paths[:dest]}", server.host, :color => :green
- else
- failed_servers << server.host
+ Dir.chdir(options[:chdir] || '.') do
+ ok = system(rsync_cmd)
+ failed_servers << server.host unless ok
end
end