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 +1 -0
- data/README.md +6 -10
- data/lib/chef/knife/lastrun.rb +18 -15
- data/lib/knife-lastrun/version.rb +1 -1
- metadata +3 -2
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# knife-
|
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
|
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 "
|
38
|
-
|
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.
|
data/lib/chef/knife/lastrun.rb
CHANGED
@@ -28,10 +28,7 @@ module GoulahPlugins
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# time
|
31
|
-
time_entries =
|
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 =
|
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 = [
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
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
|