Skip to content

Instantly share code, notes, and snippets.

@maxim
Last active December 19, 2015 02:59
Show Gist options
  • Select an option

  • Save maxim/5887312 to your computer and use it in GitHub Desktop.

Select an option

Save maxim/5887312 to your computer and use it in GitHub Desktop.
require 'kitchen'
require 'tmpdir'
module Kitchen
class GzippedChefDataUploader < ChefDataUploader
def upload_path(scp, path, dir = File.basename(path))
if File.directory?(path)
tmp_root = Dir.mktmpdir('gzipped_chef_uploader')
gzip_path = "#{tmp_root}/#{dir}.tar.gz"
system "cd #{path} && tar -zcf #{gzip_path} ."
super(scp, gzip_path, "#{dir}.tar.gz")
scp.session.exec! "cd #{chef_home} && mkdir #{dir} && " +
"tar -zxf #{dir}.tar.gz -C #{dir} && rm #{dir}.tar.gz"
else
super
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment