supply_drop 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -46,7 +46,7 @@ defines the base directory containing your puppet configs that will be rsynced t
46
46
 
47
47
  defines where on the server the puppet configuration files are synced to.
48
48
 
49
- set :puppet_command, 'puppet'
49
+ set :puppet_command, 'puppet apply'
50
50
 
51
51
  allows you to override the puppet command that is run if puppet is not on the path.
52
52
 
@@ -62,11 +62,28 @@ the parameters that are passed to the puppet call.
62
62
 
63
63
  these are patterns that are passed as rsync --exclude flags when pushing your puppet configs to the box.
64
64
 
65
+ set :puppet_parallel_rsync, true
66
+
67
+ determines whether the rsync commands for multiple servers are run in parallel threads or serially
68
+
69
+
70
+ ### Handling Legacy Puppet
71
+
72
+ Puppet deprecated the implicit invocation of apply [in the 2.6.x series](https://github.com/puppetlabs/puppet/commit/a23cfd869f90ae4456dded6e5a1c82719b128f01).
73
+
74
+ The default behavior of supply_drop includes `apply` keyword in its commands, but if you need compatibility with older versions of puppet, set the `puppet_command` variable to omit it.
75
+
76
+ You'll need to do this if you see errors like this:
77
+
78
+ Could not parse for environment production: Could not find file /home/.../supply_drop/apply.pp
79
+
65
80
  ### How to contribute
66
81
 
67
82
  If you write anything complicated, write a test for it. Test that your changes work using vagrant. Send a pull request. Easy peezy.
68
83
 
69
84
  ### Contributors
70
85
 
86
+ * Paul Hinze [phinze](https://github.com/phinze "github")
71
87
  * Paul Gross [pgr0ss](https://github.com/pgr0ss "github")
72
88
  * Drew Olson [drewolson](https://github.com/drewolson "github")
89
+ * Dave Pirotte [dpirotte](https://github.com/dpirotte "github")
data/lib/supply_drop.rb CHANGED
@@ -1,15 +1,18 @@
1
1
  require 'supply_drop/rsync'
2
+ require 'supply_drop/async_enumerable'
3
+ require 'supply_drop/util'
2
4
 
3
5
  Capistrano::Configuration.instance.load do
4
6
  namespace :puppet do
5
7
  set :puppet_source, '.'
6
8
  set :puppet_destination, '/tmp/supply_drop'
7
- set :puppet_command, 'puppet'
9
+ set :puppet_command, 'puppet apply'
8
10
  set :puppet_lib, "#{puppet_destination}/modules"
9
11
  set :puppet_parameters, lambda { puppet_verbose ? '--debug --trace puppet.pp' : 'puppet.pp' }
10
12
  set :puppet_verbose, false
11
13
  set :puppet_excludes, %w(.git .svn)
12
14
  set :puppet_stream_output, false
15
+ set :puppet_parallel_rsync, true
13
16
 
14
17
  namespace :bootstrap do
15
18
  desc "installs puppet via rubygems on an osx host"
@@ -31,10 +34,11 @@ Capistrano::Configuration.instance.load do
31
34
 
32
35
  desc "pushes the current puppet configuration to the server"
33
36
  task :update_code, :except => { :nopuppet => true } do
34
- find_servers_for_task(current_task).each do |server|
35
- rsync_cmd = Rsync.command(
37
+ servers = SupplyDrop::Util.optionally_async(find_servers_for_task(current_task), puppet_parallel_rsync)
38
+ servers.each do |server|
39
+ rsync_cmd = SupplyDrop::Rsync.command(
36
40
  puppet_source,
37
- Rsync.remote_address(server.user || fetch(:user, ENV['USER']), server.host, puppet_destination),
41
+ SupplyDrop::Rsync.remote_address(server.user || fetch(:user, ENV['USER']), server.host, puppet_destination),
38
42
  :delete => true,
39
43
  :excludes => puppet_excludes,
40
44
  :ssh => { :keys => ssh_options[:keys], :config => ssh_options[:config] }
@@ -0,0 +1,9 @@
1
+ module SupplyDrop
2
+ module AsyncEnumerable
3
+ def each(&block)
4
+ self.map do |item|
5
+ Thread.new { block.call(item) }
6
+ end.each(&:join)
7
+ end
8
+ end
9
+ end
@@ -1,34 +1,36 @@
1
- class Rsync
2
- class << self
3
- def command(from, to, options={})
4
- flags = ['-az']
5
- flags << '--delete' if options[:delete]
6
- flags << excludes(options[:excludes]) if options.has_key?(:excludes)
7
- flags << ssh_options(options[:ssh]) if options.has_key?(:ssh)
1
+ module SupplyDrop
2
+ class Rsync
3
+ class << self
4
+ def command(from, to, options={})
5
+ flags = ['-az']
6
+ flags << '--delete' if options[:delete]
7
+ flags << excludes(options[:excludes]) if options.has_key?(:excludes)
8
+ flags << ssh_options(options[:ssh]) if options.has_key?(:ssh)
8
9
 
9
- "rsync #{flags.compact.join(' ')} #{from} #{to}"
10
- end
10
+ "rsync #{flags.compact.join(' ')} #{from} #{to}"
11
+ end
11
12
 
12
- def remote_address(user, host, path)
13
- user_with_host = [user, host].compact.join('@')
14
- [user_with_host, path].join(':')
15
- end
13
+ def remote_address(user, host, path)
14
+ user_with_host = [user, host].compact.join('@')
15
+ [user_with_host, path].join(':')
16
+ end
16
17
 
17
- def excludes(patterns)
18
- [patterns].flatten.map { |p| "--exclude=#{p}" }
19
- end
18
+ def excludes(patterns)
19
+ [patterns].flatten.map { |p| "--exclude=#{p}" }
20
+ end
20
21
 
21
- def ssh_options(options)
22
- mapped_options = options.map do |key, value|
23
- next unless value
22
+ def ssh_options(options)
23
+ mapped_options = options.map do |key, value|
24
+ next unless value
24
25
 
25
- case key
26
- when :keys then [value].flatten.select { |k| File.exist?(k) }.map { |k| "-i #{k}" }
27
- when :config then "-F #{value}"
28
- end
29
- end.compact
26
+ case key
27
+ when :keys then [value].flatten.select { |k| File.exist?(k) }.map { |k| "-i #{k}" }
28
+ when :config then "-F #{value}"
29
+ end
30
+ end.compact
30
31
 
31
- %[-e "ssh #{mapped_options.join(' ')}"] unless mapped_options.empty?
32
+ %[-e "ssh #{mapped_options.join(' ')}"] unless mapped_options.empty?
33
+ end
32
34
  end
33
35
  end
34
36
  end
@@ -0,0 +1,11 @@
1
+ module SupplyDrop
2
+ module Util
3
+ def self.optionally_async(collection, async)
4
+ if async
5
+ collection.extend SupplyDrop::AsyncEnumerable
6
+ else
7
+ collection
8
+ end
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supply_drop
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
4
+ hash: 11
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Pitluga
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-11 00:00:00 -05:00
19
- default_executable:
18
+ date: 2011-12-05 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description: See http://github.com/pitluga/supply_drop
@@ -30,14 +29,15 @@ extra_rdoc_files: []
30
29
  files:
31
30
  - README.md
32
31
  - Rakefile
32
+ - lib/supply_drop/async_enumerable.rb
33
33
  - lib/supply_drop/rsync.rb
34
+ - lib/supply_drop/util.rb
34
35
  - lib/supply_drop.rb
35
36
  - examples/ec2/Capfile
36
37
  - examples/ec2/puppet.pp
37
38
  - examples/vagrant/Capfile
38
39
  - examples/vagrant/puppet.pp
39
40
  - examples/vagrant/Vagrantfile
40
- has_rdoc: true
41
41
  homepage: http://github.com/pitluga/supply_drop
42
42
  licenses: []
43
43
 
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  requirements: []
68
68
 
69
69
  rubyforge_project:
70
- rubygems_version: 1.3.7
70
+ rubygems_version: 1.8.10
71
71
  signing_key:
72
72
  specification_version: 3
73
73
  summary: Serverless puppet with capistrano