diff --git a/lib/kitchen/transport/rsync.rb b/lib/kitchen/transport/rsync.rb index 302c3aa..e45817e 100644 --- a/lib/kitchen/transport/rsync.rb +++ b/lib/kitchen/transport/rsync.rb @@ -33,6 +33,8 @@ def create_new_connection(options, &block) @connection.close end + $kitchen_rsync_opts = self.[](:rsync_options) if self.[](:rsync_options) + @connection_options = options @connection = self.class::Connection.new(options, &block) end @@ -50,7 +52,12 @@ def upload(locals, remote) rsync_candidates = locals.select {|path| File.directory?(path) && File.basename(path) != 'cache' } ssh_command = "ssh #{ssh_args.join(' ')}" copy_identity - rsync_cmd = "/usr/bin/rsync -e '#{ssh_command}' -az#{logger.level == :debug ? 'vv' : ''} --delete #{rsync_candidates.join(' ')} #{@session.options[:user]}@#{@session.host}:#{remote}" + rsync_cmd = "/usr/bin/rsync -e '#{ssh_command}' -az#{logger.level == :debug ? 'vv' : ''} --delete " + if $kitchen_rsync_opts && $kitchen_rsync_opts[:excludes] + rsync_cmd << $kitchen_rsync_opts[:excludes].map { |e| "--exclude '#{e}'" }.join(' ') + rsync_cmd << ' ' + end + rsync_cmd << "#{rsync_candidates.join(' ')} #{@session.options[:user]}@#{@session.host}:#{remote}" logger.debug("[rsync] Running rsync command: #{rsync_cmd}") ret = [] time = Benchmark.realtime do