knife-lastrun 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # knife-lastlog
1
+ # knife-lastrun
2
2
 
3
3
  A plugin for Chef::Knife which displays node metadata about the last chef run.
4
4
 
5
5
  ## Usage
6
6
 
7
- Supply a role name to get a dump of its hierarchy, pass -i for the roles that also include it
7
+ Supply a node name to get metrics from the last chef run
8
8
 
9
9
  ```
10
10
  % knife node lastrun jgoulah.vm.mydomain.com
@@ -34,12 +34,8 @@ knife-lastrun is available on rubygems.org - if you have that source in your gem
34
34
  in /etc/chef/client.rb
35
35
 
36
36
  ```
37
- require "/var/chef/handlers/lastrun_update.rb"
38
- report_handlers << LastRunUpdateHandler.new
37
+ require "lastrun_update"
38
+ handler = LastRunUpdateHandler.new
39
+ report_handlers << handler
40
+ exception_handlers << handler
39
41
  ```
40
-
41
-
42
-
43
- #### Script install
44
-
45
- Copy the knife-lastrun script from lib/chef/knife/lastrun.rb to your ~/.chef/plugins/knife directory.
@@ -28,10 +28,7 @@ module GoulahPlugins
28
28
  end
29
29
 
30
30
  # time
31
- time_entries = [ h.color('Status', :bold),
32
- h.color('Elapsed Time', :bold),
33
- h.color('Start Time', :bold),
34
- h.color('End Time', :bold) ]
31
+ time_entries = header('Status', 'Elapsed Time', 'Start Time', 'End Time');
35
32
 
36
33
  time_entries << node[:lastrun][:status]
37
34
  [:elapsed, :start, :end].each do |time|
@@ -41,10 +38,7 @@ module GoulahPlugins
41
38
  ui.msg "\n"
42
39
 
43
40
  # updated resources
44
- log_entries = [ h.color('Recipe', :bold),
45
- h.color('Action', :bold),
46
- h.color('Resource Type', :bold),
47
- h.color('Resource', :bold) ]
41
+ log_entries = header('Recipe', 'Action', 'Resource Type', 'Resource');
48
42
 
49
43
  node[:lastrun][:updated_resources].each do |log_entry|
50
44
  log_entries << "#{log_entry[:cookbook_name]}::#{log_entry[:recipe_name]}"
@@ -57,15 +51,24 @@ module GoulahPlugins
57
51
  ui.msg "\n"
58
52
 
59
53
  # debug stuff
60
- debug_entries = [ h.color('Backtrace', :bold),
61
- h.color('Exception', :bold),
62
- h.color('Formatted Exception', :bold) ]
63
- [:backtrace, :exception, :formatted_exception].each do |msg|
64
- debug_entries << (node[:lastrun][:debug][msg] ? node[:lastrun][:debug][msg].to_s : "none")
65
- end
66
- ui.msg h.list(debug_entries, :columns_down, 2)
54
+ debug_entries = []
55
+ debug_entries << h.color('Backtrace', :bold)
56
+ debug_entries << (node[:lastrun][:debug][:backtrace] ? node[:lastrun][:debug][:backtrace].join("\n") : "none")
57
+ debug_entries << ""
58
+
59
+ debug_entries << h.color('Exception', :bold)
60
+ debug_entries << (node[:lastrun][:debug][:formatted_exception] ? node[:lastrun][:debug][:formatted_exception].strip : "none")
61
+ ui.msg h.list(debug_entries, :rows)
67
62
  ui.msg "\n"
68
63
 
69
64
  end
65
+
66
+ def header(*args)
67
+ entry = []
68
+ args.each do |arg|
69
+ entry << h.color(arg, :bold)
70
+ end
71
+ entry
72
+ end
70
73
  end
71
74
  end
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module NodeLastrun
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Goulah
@@ -28,6 +28,7 @@ extensions: []
28
28
  extra_rdoc_files: []
29
29
 
30
30
  files:
31
+ - .gitignore
31
32
  - README.md
32
33
  - knife-lastrun.gemspec
33
34
  - lib/chef/knife/lastrun.rb