From ba301b0c8d77ae2f455d3a2d736968c981b8c757 Mon Sep 17 00:00:00 2001 From: elijah Date: Sun, 13 Jan 2013 20:27:29 -0800 Subject: 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. --- lib/leap_cli/remote/plugin.rb | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'lib/leap_cli/remote') 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 -- cgit v1.2.3