dust-deploy 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
data/changelog.md CHANGED
@@ -1,11 +1,21 @@
1
1
  Changelog
2
2
  =============
3
3
 
4
+ 0.7.4
5
+ ------------
6
+
7
+ - node.install_package now repsects options
8
+ - make sure openssh-clients is installed on rpm machines before trying to scp
9
+ - node.exec now supports :live => true option, which displays stdout/stderr live
10
+ - 'dust system_update' uses this new live function, so you can now watch the update process live
11
+
12
+
4
13
  0.7.3
5
14
  ------------
6
15
 
7
16
  - fixes issue in node.get_home (errors when there were two similar usernames or two passwd entries for the same user)
8
17
 
18
+
9
19
  0.7.2
10
20
  ------------
11
21
 
@@ -55,8 +55,8 @@ module Dust
55
55
  opts = options.clone
56
56
 
57
57
  opts[:indent] += 1
58
- print_msg "#{grey}#{ret[:stdout].chomp}#{none}\n", opts unless ret[:stdout].empty?
59
- print_msg "#{red}#{ret[:stderr].chomp}#{none}\n", opts unless ret[:stderr].empty?
58
+ print_msg "#{green 0}#{ret[:stdout].chomp}#{none}\n", opts unless ret[:stdout].empty?
59
+ print_msg "#{red 0}#{ret[:stderr].chomp}#{none}\n", opts unless ret[:stderr].empty?
60
60
  end
61
61
 
62
62
  # indent according to options[:indent]
data/lib/dust/server.rb CHANGED
@@ -50,7 +50,7 @@ module Dust
50
50
  @ssh.close
51
51
  end
52
52
 
53
- def exec command
53
+ def exec command, options={:live => false}
54
54
  sudo_authenticated = false
55
55
  stdout = ''
56
56
  stderr = ''
@@ -78,10 +78,16 @@ module Dust
78
78
  sudo_authenticated = true
79
79
  else
80
80
  stdout += data
81
- end
81
+ end
82
+
83
+ Dust.print_msg "#{Dust.green 0}#{data}#{Dust.none}", :indent => 0 if options[:live] and not data.empty?
84
+ end
85
+
86
+ channel.on_extended_data do |ch, type, data|
87
+ stderr += data
88
+ Dust.print_msg "#{Dust.red 0}#{data}#{Dust.none}", :indent => 0 if options[:live] and not data.empty?
82
89
  end
83
90
 
84
- channel.on_extended_data { |ch, type, data| stderr += data }
85
91
  channel.on_request('exit-status') { |ch, data| exit_code = data.read_long }
86
92
  channel.on_request('exit-signal') { |ch, data| exit_signal = data.read_long }
87
93
  end
@@ -124,6 +130,9 @@ module Dust
124
130
  def scp source, destination, options = {}
125
131
  options = default_options.merge options
126
132
 
133
+ # make sure scp is installed on client
134
+ install_package 'openssh-clients', :quiet => true if uses_rpm?
135
+
127
136
  Dust.print_msg "deploying #{File.basename source}", options
128
137
 
129
138
  # if in sudo mode, copy file to temporary place, then move using sudo
@@ -244,11 +253,11 @@ module Dust
244
253
  options = default_options.merge options
245
254
  options[:env] ||= ''
246
255
 
247
- if package_installed? package, :quiet=>true
248
- return Dust.print_ok "package #{package} already installed"
256
+ if package_installed? package, :quiet => true
257
+ return Dust.print_ok "package #{package} already installed", options
249
258
  end
250
259
 
251
- Dust.print_msg "installing #{package}"
260
+ Dust.print_msg "installing #{package}", options
252
261
 
253
262
  if uses_apt?
254
263
  exec "DEBIAN_FRONTEND=noninteractive aptitude install -y #{package}"
@@ -257,11 +266,11 @@ module Dust
257
266
  elsif uses_rpm?
258
267
  exec "yum install -y #{package}"
259
268
  else
260
- Dust.print_failed 'install_package only supports apt, emerge and rpm systems at the moment'
269
+ Dust.print_failed 'install_package only supports apt, emerge and rpm systems at the moment', options
261
270
  end
262
271
 
263
272
  # check if package actually was installed
264
- Dust.print_result package_installed? package, :quiet => true
273
+ Dust.print_result package_installed?(package, :quiet => true), options
265
274
  end
266
275
 
267
276
  def remove_package package, options = {}
@@ -287,38 +296,53 @@ module Dust
287
296
  options = default_options.merge options
288
297
 
289
298
  Dust.print_msg 'updating system repositories', options
299
+ puts if options[:live]
290
300
 
291
301
  if uses_apt?
292
- Dust.print_result exec('aptitude update')[:exit_code], options
302
+ ret = exec 'aptitude update', options
293
303
  elsif uses_emerge?
294
- Dust.print_result exec('emerge --sync')[:exit_code], options
304
+ ret = exec 'emerge --sync', options
295
305
  elsif uses_rpm?
296
- Dust.print_result exec('yum check-update')[:exit_code], options
306
+ ret = exec 'yum check-update', options
297
307
  else
298
- Dust.print_failed '', options
308
+ return Dust.print_failed '', options
309
+ end
310
+
311
+ if options[:live]
312
+ puts
313
+ else
314
+ Dust.print_result ret[:exit_code], options
299
315
  end
316
+
317
+ ret[:exit_code]
300
318
  end
301
319
 
302
320
  def system_update options = {}
303
- options = default_options.merge options
321
+ options = default_options.merge(:live => true).merge(options)
304
322
 
305
323
  update_repos
306
324
 
307
325
  Dust.print_msg 'installing system updates', options
326
+ puts if options[:live]
308
327
 
309
328
  if uses_apt?
310
- ret = exec 'DEBIAN_FRONTEND=noninteractive aptitude full-upgrade -y'
329
+ ret = exec 'DEBIAN_FRONTEND=noninteractive aptitude full-upgrade -y', options
311
330
  elsif uses_emerge?
312
- ret = exec 'emerge -uND @world'
331
+ ret = exec 'emerge -uND @world', options
313
332
  elsif uses_rpm?
314
- ret = exec 'yum upgrade -y'
333
+ ret = exec 'yum upgrade -y', options
315
334
  else
316
- Dust.print_failed "\nsystem not (yet) supported", options
335
+ Dust.print_failed 'system not (yet) supported', options
317
336
  return false
318
337
  end
319
-
320
- Dust.print_result ret[:exit_code], options
321
- Dust.print_ret ret, options
338
+
339
+ if options[:live]
340
+ puts
341
+ else
342
+ Dust.print_result ret[:exit_code], options
343
+ end
344
+
345
+ ret[:exit_code]
322
346
  end
323
347
 
324
348
  # determining the system packet manager has to be done without facter
@@ -350,8 +374,8 @@ module Dust
350
374
  def is_os? os_list, options = {}
351
375
  options = default_options(:quiet => true).merge options
352
376
 
353
- Dust.print_msg "checking if this machine runs #{os_list.join(' or ')}", options
354
- collect_facts options
377
+ Dust.print_msg "checking if this machine runs #{os_list.join(' or ')}", options
378
+ return Dust.print_failed '', options unless collect_facts options
355
379
 
356
380
  os_list.each do |os|
357
381
  if @node['operatingsystem'].downcase == os.downcase
@@ -537,7 +561,7 @@ module Dust
537
561
  end
538
562
 
539
563
  unless package_installed? 'facter', :quiet => true
540
- install_package 'facter', :quiet => false
564
+ return false unless install_package 'facter', :quiet => false
541
565
  end
542
566
 
543
567
  Dust.print_msg "collecting additional system facts (using facter)", options
data/lib/dust/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dust
2
- VERSION = "0.7.3"
2
+ VERSION = "0.7.4"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 3
9
- version: 0.7.3
8
+ - 4
9
+ version: 0.7.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - kris kechagia
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-02-16 00:00:00 +01:00
17
+ date: 2012-02-17 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency