deb_deploy 1.1.5 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,9 +12,13 @@ or with Bundler
12
12
 
13
13
  ### Tasks
14
14
 
15
+ cap deb:bootstrap
16
+
17
+ This sets up the environment for dpkg or apt deployment, depending on your configuration.
18
+
15
19
  cap deb:deploy
16
20
 
17
- This deploys the debian packages and does a simple apt-get install of on the target servers.
21
+ This deploys the debian packages on the target servers.
18
22
 
19
23
  ### Configuration
20
24
 
@@ -40,3 +44,7 @@ the debian package manager to use (one of [dpkg, apt]).
40
44
  set :debian_stream_log, false
41
45
 
42
46
  determines whether to stream the command output.
47
+
48
+ set :debian_filter, ['*']
49
+
50
+ a glob syntax filter to determine which packages to deploy. By default all will be deployed.
@@ -4,7 +4,8 @@ module DebDeploy
4
4
  def command(from, to, options={})
5
5
  flags = ['-az']
6
6
  flags << '--delete'
7
- flags << includes(["*/","*.deb"])
7
+ flags << '--delete-excluded'
8
+ flags << includes(options[:filter])
8
9
  flags << excludes(["*"])
9
10
  flags << ssh_options(options[:ssh]) if options.has_key?(:ssh)
10
11
 
@@ -0,0 +1,17 @@
1
+ module DebDeploy
2
+ module LazyEnumerable
3
+ def each(&block)
4
+ threads = []
5
+ super do |item|
6
+ threads << Thread.new { yield item }
7
+ end
8
+ threads.each(&:join)
9
+ end
10
+
11
+ def map(&block)
12
+ super do |item|
13
+ Thread.new { Thread.current[:output] = block[item] }
14
+ end.map(&:join).map { |thread| thread[:output] }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ require 'deb_deploy/util/collection_utils'
2
+
3
+ module Enumerable
4
+ def async
5
+ self.clone.extend DebDeploy::LazyEnumerable
6
+ end
7
+ end
8
+
data/lib/deb_deploy.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'deb_deploy/rsync'
2
2
  require 'deb_deploy/logger/batch'
3
3
  require 'deb_deploy/logger/stream'
4
+ require 'deb_deploy/util/parallel_enumerable'
4
5
 
5
6
  Capistrano::Configuration.instance.load do
6
7
  namespace :deb do
@@ -8,6 +9,7 @@ Capistrano::Configuration.instance.load do
8
9
  set :debian_target, '/tmp/deb_deploy'
9
10
  set :debian_package_manager, 'dpkg'
10
11
  set :debian_stream_log, false
12
+ set :debian_filter, ['*']
11
13
 
12
14
  namespace :bootstrap do
13
15
  desc "prepares remote hosts for debian deployment based on selected package manager (dpkg or apt)"
@@ -39,21 +41,58 @@ Capistrano::Configuration.instance.load do
39
41
 
40
42
  logger.debug "Dependencies installed"
41
43
 
42
- run "echo 'deb file:#{debian_target} ./' > #{debian_target}/deb_deploy.list"
44
+ put "deb file:#{debian_target} ./", "#{debian_target}/deb_deploy.list"
43
45
  sudo "mv #{debian_target}/deb_deploy.list /etc/apt/sources.list.d/deb_deploy.list"
44
46
 
47
+ put "Package: *\nPin: origin\nPin-Priority: 900\n", "#{debian_target}/00debdeploy"
48
+ sudo "mv #{debian_target}/00debdeploy /etc/apt/preferences.d/00debdeploy"
49
+
50
+ run "cd #{debian_target} && apt-ftparchive packages . | gzip -9c > Packages.gz"
51
+
45
52
  logger.debug "Set up local debian repository"
46
53
  end
47
54
 
48
55
  end
49
56
 
57
+ namespace :teardown do
58
+ desc "cleans up deb_deploy files from remote hosts based on selected package manager (dpkg or apt)"
59
+ task :default do
60
+ case debian_package_manager
61
+ when "dpkg"
62
+ dpkg
63
+ when "apt"
64
+ apt
65
+ else
66
+ raise "#{debian_package_manager} is an unsupported package manager. Only dpkg and apt are supported"
67
+ end
68
+ end
69
+
70
+ desc "cleans up deb_deploy directory (#{debian_target})"
71
+ task :dpkg do
72
+ run "rm -rf #{debian_target}"
73
+ logger.debug "Removed deployment directory"
74
+ end
75
+
76
+ desc "cleans up deb_deploy directory (#{debian_target}) and local debian repository from remote hosts"
77
+ task :apt do
78
+ run "rm -rf #{debian_target}"
79
+
80
+ sudo "rm /etc/apt/sources.list.d/deb_deploy.list"
81
+
82
+ sudo "rm /etc/apt/preferences.d/00debdeploy"
83
+
84
+ logger.debug "Removed local debian repository and deployment directory"
85
+ end
86
+ end
87
+
50
88
  desc "copies debian packages to the server"
51
89
  task :copy_packages do
52
90
  targets = find_servers_for_task(current_task)
53
- failed_targets = targets.map do |target|
91
+ failed_targets = targets.async.map do |target|
54
92
  copy_cmd = DebDeploy::Rsync.command(
55
93
  debian_source,
56
94
  DebDeploy::Rsync.remote_address(target.user || fetch(:user, ENV['USER']), target.host, debian_target),
95
+ :filter => ['*/'] + debian_filter.map {|x| "#{x}.deb"},
57
96
  :ssh => {
58
97
  :keys => ssh_options[:keys],
59
98
  :config => ssh_options[:config],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deb_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-08 00:00:00.000000000 Z
12
+ date: 2012-05-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: See http://github.com/jeroenr/deb_deploy
15
15
  email:
@@ -22,6 +22,8 @@ files:
22
22
  - Rakefile
23
23
  - lib/deb_deploy.rb
24
24
  - lib/deb_deploy/rsync.rb
25
+ - lib/deb_deploy/util/parallel_enumerable.rb
26
+ - lib/deb_deploy/util/collection_utils.rb
25
27
  - lib/deb_deploy/scp.rb
26
28
  - lib/deb_deploy/logger/batch.rb
27
29
  - lib/deb_deploy/logger/stream.rb