supply_drop 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  supply_drop is a capistrano plugin to facitiate provisioning servers with puppet, without using the puppet server. It works by simply rsyncing your puppet configuration files to your servers and running puppet apply. It strives to allow you to write idiomatic puppet scripts while being as lightweight as possible.
4
4
 
5
+ [![Build Status](https://secure.travis-ci.org/pitluga/supply_drop.png)](http://travis-ci.org/pitluga/supply_drop)
6
+
5
7
  ### Installation
6
8
 
7
9
  gem install supply_drop
@@ -10,7 +10,7 @@ module SupplyDrop
10
10
  SupplyDrop::Rsync.remote_address(server.user || fetch(:user, ENV['USER']), server.host, puppet_destination),
11
11
  :delete => true,
12
12
  :excludes => puppet_excludes,
13
- :ssh => { :keys => ssh_options[:keys], :config => ssh_options[:config], :port => fetch(:port, nil) }
13
+ :ssh => ssh_options.merge(server.options[:ssh_options]||{})
14
14
  )
15
15
  logger.debug rsync_cmd
16
16
  server.host unless system rsync_cmd
@@ -19,19 +19,148 @@ module SupplyDrop
19
19
  [patterns].flatten.map { |p| "--exclude=#{p}" }
20
20
  end
21
21
 
22
+ #
23
+ # Convert Net::SSH options into OpenSSH options.
24
+ #
25
+ # For a list of the options normally support by Net::SSH (and thus Capistrano), see
26
+ # http://net-ssh.github.com/net-ssh/classes/Net/SSH.html#method-c-start
27
+ #
28
+ # Also, to see how Net::SSH does the opposite of the conversion we are doing here, check out:
29
+ # https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/config.rb
30
+ #
31
+ # API mismatch:
32
+ #
33
+ # * many OpenSSH options not supported
34
+ # * some options only make sense for Net::SSH
35
+ # * compression: for Net::SSH, this option is supposed to accept true, false, or algorithm. OpenSSH accepts 'yes' or 'no'
36
+ #
22
37
  def ssh_options(options)
23
38
  mapped_options = options.map do |key, value|
24
39
  next unless value
25
40
 
26
41
  case key
27
- when :keys then [value].flatten.select { |k| File.exist?(k) }.map { |k| "-i #{k}" }
28
- when :config then "-F #{value}"
29
- when :port then "-p #{value}"
42
+ when :auth_methods then opt_auth_methods(value)
43
+ when :bind_address then opt('BindAddress', value)
44
+ when :compression then opt('Compression', value ? 'yes' : 'no')
45
+ when :compression_level then opt('CompressionLevel', value.to_i)
46
+ when :config then "-F '#{value}'"
47
+ when :encryption then opt('Ciphers', [value].flatten.join(','))
48
+ when :forward_agent then opt('ForwardAgent', value)
49
+ when :global_known_hosts_file then opt('GlobalKnownHostsFile', value)
50
+ when :hmac then opt('MACs', [value].flatten.join(','))
51
+ when :host_key then opt('HostKeyAlgorithms', [value].flatten.join(','))
52
+ when :host_key_alias then opt('HostKeyAlias', value)
53
+ when :host_name then opt('HostName', value)
54
+ when :kex then opt('KexAlgorithms', [value].flatten.join(','))
55
+ when :key_data then nil # not supported
56
+ when :keys then [value].flatten.select { |k| File.exist?(k) }.map { |k| "-i '#{k}'" }
57
+ when :keys_only then opt('IdentitiesOnly', value ? 'yes' : 'no')
58
+ when :languages then nil # not applicable
59
+ when :logger then nil # not applicable
60
+ when :paranoid then opt('StrictHostKeyChecking', value ? 'yes' : 'no')
61
+ when :passphrase then nil # not supported
62
+ when :password then nil # not supported
63
+ when :port then "-p #{value.to_i}"
64
+ when :properties then nil # not applicable
65
+ when :proxy then nil # not applicable
66
+ when :rekey_blocks_limit then nil # not supported
67
+ when :rekey_limit then opt('RekeyLimit', reverse_interpret_size(value))
68
+ when :rekey_packet_limit then nil # not supported
69
+ when :timeout then opt('ConnectTimeout', value.to_i)
70
+ when :user then "-l #{value}"
71
+ when :user_known_hosts_file then multi_opt('UserKnownHostsFile', value)
72
+ when :verbose then opt('LogLevel', interpret_log_level(value))
30
73
  end
31
74
  end.compact
32
75
 
33
76
  %[-e "ssh #{mapped_options.join(' ')}"] unless mapped_options.empty?
34
77
  end
78
+
79
+ private
80
+
81
+ def opt(option_name, option_value)
82
+ "-o #{option_name}='#{option_value}'"
83
+ end
84
+
85
+ def multi_opt(option_name, option_values)
86
+ [option_values].flatten.map do |value|
87
+ opt(option_name, value)
88
+ end.join(' ')
89
+ end
90
+
91
+ #
92
+ # In OpenSSH, password and pubkey default to 'yes', hostbased defaults to 'no'.
93
+ # Regardless, if :auth_method is configured, then we explicitly disable methods not included.
94
+ #
95
+ def opt_auth_methods(value)
96
+ value = [value].flatten
97
+ opts = []
98
+ if value.any?
99
+ if value.include? 'password'
100
+ opts << opt('PasswordAuthentication', 'yes')
101
+ else
102
+ opts << opt('PasswordAuthentication', 'no')
103
+ end
104
+ if value.include? 'publickey'
105
+ opts << opt('PubkeyAuthentication', 'yes')
106
+ else
107
+ opts << opt('PubkeyAuthentication', 'no')
108
+ end
109
+ if value.include? 'hostbased'
110
+ opts << opt('HostbasedAuthentication', 'yes')
111
+ else
112
+ opts << opt('HostbasedAuthentication', 'no')
113
+ end
114
+ end
115
+ if opts.any?
116
+ return opts.join(' ')
117
+ else
118
+ nil
119
+ end
120
+ end
121
+
122
+ #
123
+ # Converts the given integer size in bytes into a string with 'K', 'M', 'G' suffix, as appropriate.
124
+ #
125
+ # reverse of interpret_size in https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/config.rb
126
+ #
127
+ def reverse_interpret_size(size)
128
+ size = size.to_i
129
+ if size < 1024
130
+ "#{size}"
131
+ elsif size < 1024 * 1024
132
+ "#{size/1024}K"
133
+ elsif size < 1024 * 1024 * 1024
134
+ "#{size/(1024*1024)}M"
135
+ else
136
+ "#{size/(1024*1024*1024)}G"
137
+ end
138
+ end
139
+
140
+ def interpret_log_level(level)
141
+ if level.is_a? Symbol
142
+ case level
143
+ when :debug then "DEBUG"
144
+ when :info then "INFO"
145
+ when :warn then "ERROR"
146
+ when :error then "ERROR"
147
+ when :fatal then "FATAL"
148
+ else "INFO"
149
+ end
150
+ elsif level.is_a? Integer
151
+ case level
152
+ when Logger::DEBUG then "DEBUG"
153
+ when Logger::INFO then "INFO"
154
+ when Logger::WARN then "ERROR"
155
+ when Logger::ERROR then "ERROR"
156
+ when Logger::FATAL then "FATAL"
157
+ else "INFO"
158
+ end
159
+ else
160
+ "INFO"
161
+ end
162
+ end
163
+
35
164
  end
36
165
  end
37
166
  end
@@ -65,10 +65,10 @@ Capistrano::Configuration.instance.load do
65
65
 
66
66
  desc "runs puppet with --noop flag to show changes"
67
67
  task :noop, :except => { :nopuppet => true } do
68
+ supply_drop.lock
68
69
  transaction do
69
70
  on_rollback { supply_drop.unlock }
70
71
  supply_drop.prepare
71
- supply_drop.lock
72
72
  update_code
73
73
  supply_drop.noop
74
74
  supply_drop.unlock
@@ -77,10 +77,10 @@ Capistrano::Configuration.instance.load do
77
77
 
78
78
  desc "applies the current puppet config to the server"
79
79
  task :apply, :except => { :nopuppet => true } do
80
+ supply_drop.lock
80
81
  transaction do
81
82
  on_rollback { supply_drop.unlock }
82
83
  supply_drop.prepare
83
- supply_drop.lock
84
84
  update_code
85
85
  supply_drop.apply
86
86
  supply_drop.unlock
@@ -89,7 +89,13 @@ Capistrano::Configuration.instance.load do
89
89
 
90
90
  desc "clears the puppet lockfile on the server."
91
91
  task :remove_lock, :except => { :nopuppet => true} do
92
- supply_drop.lock
92
+ logger.important "WARNING: puppet:remove_lock is depricated, please use puppet:unlock instead"
93
+ supply_drop.unlock
94
+ end
95
+
96
+ desc "clears the puppet lockfile on the server."
97
+ task :unlock, :except => { :nopuppet => true} do
98
+ supply_drop.unlock
93
99
  end
94
100
  end
95
101
  end
metadata CHANGED
@@ -1,51 +1,41 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: supply_drop
3
- version: !ruby/object:Gem::Version
4
- hash: 47
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 12
9
- - 0
10
- version: 0.12.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.13.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Tony Pitluga
14
9
  - Paul Hinze
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-10-16 00:00:00 -05:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2012-12-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: capistrano
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
26
18
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 49
31
- segments:
32
- - 2
33
- - 5
34
- - 21
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
35
22
  version: 2.5.21
36
23
  type: :runtime
37
- version_requirements: *id001
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 2.5.21
38
31
  description: See http://github.com/pitluga/supply_drop
39
- email:
32
+ email:
40
33
  - tony.pitluga@gmail.com
41
34
  - paul.t.hinze@gmail.com
42
35
  executables: []
43
-
44
36
  extensions: []
45
-
46
37
  extra_rdoc_files: []
47
-
48
- files:
38
+ files:
49
39
  - README.md
50
40
  - Rakefile
51
41
  - lib/supply_drop/async_enumerable.rb
@@ -59,39 +49,28 @@ files:
59
49
  - lib/supply_drop/writer/file.rb
60
50
  - lib/supply_drop/writer/streaming.rb
61
51
  - lib/supply_drop.rb
62
- has_rdoc: true
63
52
  homepage: http://github.com/pitluga/supply_drop
64
53
  licenses: []
65
-
66
54
  post_install_message:
67
55
  rdoc_options: []
68
-
69
- require_paths:
56
+ require_paths:
70
57
  - lib
71
- required_ruby_version: !ruby/object:Gem::Requirement
58
+ required_ruby_version: !ruby/object:Gem::Requirement
72
59
  none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
- version: "0"
80
- required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
65
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
89
70
  requirements: []
90
-
91
71
  rubyforge_project:
92
- rubygems_version: 1.3.7
72
+ rubygems_version: 1.8.21
93
73
  signing_key:
94
74
  specification_version: 3
95
75
  summary: Masterless puppet with capistrano
96
76
  test_files: []
97
-