capistrano-paratrooper-chef 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,7 @@
1
+ require "find"
1
2
  require "json"
2
3
  require "tempfile"
4
+ require "capistrano-paratrooper-chef/tarwriter"
3
5
  require "capistrano-paratrooper-chef/version"
4
6
 
5
7
 
@@ -221,16 +223,17 @@ Capistrano::Configuration.instance.load do
221
223
  task :upload, :except => { :no_release => true } do
222
224
  librarian_chef.fetch
223
225
 
224
- kitchen_paths = [cookbooks_paths, roles_path, databags_path].flatten.compact.select{|d| File.exists?(d)}
225
- tarball = Tempfile.new("kitchen.tar")
226
- begin
227
- tarball.close
228
- system "tar -czf #{tarball.path} #{kitchen_paths.join(' ')}"
229
- top.upload tarball.path, remote_path("kitchen.tar"), :via => :scp
230
- run "cd #{fetch(:chef_working_dir)} && tar -xzf kitchen.tar"
231
- ensure
232
- tarball.unlink
226
+ stream = StringIO.new
227
+ TarWriter.new(stream) do |writer|
228
+ kitchen_paths = [cookbooks_paths, roles_path, databags_path].flatten.compact.select{|d| File.exists?(d)}
229
+ Find.find(*kitchen_paths) do |path|
230
+ writer.add(path)
231
+ end
233
232
  end
233
+
234
+ stream.seek(0)
235
+ put stream.read, remote_path("kitchen.tar"), :via => :scp
236
+ run "cd #{fetch(:chef_working_dir)} && tar -xf kitchen.tar"
234
237
  end
235
238
  end
236
239
  end
@@ -3,11 +3,13 @@ require 'capistrano-paratrooper-chef'
3
3
  Capistrano::Configuration.instance.load do
4
4
  namespace :paratrooper do
5
5
  namespace :chef do
6
+ set :chef_solo_path, "/opt/chef/bin/chef-solo"
7
+
6
8
  desc "Installs chef (by omnibus installer)"
7
9
  task :install_omnibus_chef do
8
10
  run "curl -L http://www.opscode.com/chef/install.sh | #{top.sudo} bash"
9
11
  end
10
- after "deploy:setup" "paratrooper:chef:install_omnibus_chef"
12
+ after "deploy:setup", "paratrooper:chef:install_omnibus_chef"
11
13
  end
12
14
  end
13
15
  end
@@ -0,0 +1,45 @@
1
+ require "rubygems/package"
2
+
3
+
4
+ # Add TarHeader::set_mtime() for hack timestamp
5
+ class Gem::Package::TarHeader
6
+ @@mtime = 0
7
+
8
+ def self.set_mtime(mtime)
9
+ @@mtime = mtime
10
+ end
11
+
12
+ alias :initialize_orig :initialize
13
+ def initialize(vals)
14
+ initialize_orig(vals)
15
+ @mtime = @@mtime
16
+ end
17
+ end
18
+
19
+
20
+ # Add TarWriter#add() to append content from path
21
+ class TarWriter < Gem::Package::TarWriter
22
+ alias :add_file_orig :add_file
23
+ def add_file(name, mode, mtime, &block)
24
+ Gem::Package::TarHeader.set_mtime(mtime)
25
+ add_file_orig(name, mode, &block)
26
+ end
27
+
28
+ alias :mkdir_orig :mkdir
29
+ def mkdir(name, mode, mtime)
30
+ Gem::Package::TarHeader.set_mtime(mtime)
31
+ mkdir_orig(name, mode)
32
+ end
33
+
34
+ def add(name)
35
+ stat = File.stat(name)
36
+
37
+ if File.directory?(name)
38
+ mkdir(name, stat.mode, stat.mtime)
39
+ else
40
+ add_file(name, stat.mode, stat.mtime) do |file|
41
+ file.write(File.read(name))
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,7 +1,7 @@
1
1
  module Capistrano
2
2
  module Paratrooper
3
3
  module Chef
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-paratrooper-chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,6 +43,7 @@ files:
43
43
  - lib/capistrano-paratrooper-chef.rb
44
44
  - lib/capistrano-paratrooper-chef/install.rb
45
45
  - lib/capistrano-paratrooper-chef/omnibus_install.rb
46
+ - lib/capistrano-paratrooper-chef/tarwriter.rb
46
47
  - lib/capistrano-paratrooper-chef/version.rb
47
48
  homepage: https://github.com/tk0miya/capistrano-paratrooper-chef
48
49
  licenses: []