chef-handler-motd 0.3.2 → 0.4.0
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/chef-handler-motd-0.3.2.gem +0 -0
- data/chef-handler-motd.gemspec +1 -1
- data/lib/chef-handler-motd.rb +21 -10
- metadata +3 -2
|
Binary file
|
data/chef-handler-motd.gemspec
CHANGED
data/lib/chef-handler-motd.rb
CHANGED
|
@@ -29,12 +29,26 @@ class ChefMOTD < Chef::Handler
|
|
|
29
29
|
def initialize(options = defaults)
|
|
30
30
|
@priority = options[:priority]
|
|
31
31
|
@keep_old_entries = options[:keep_old_entries]
|
|
32
|
+
@failure_message = options[:failure_message]
|
|
32
33
|
end
|
|
33
34
|
|
|
35
|
+
def report
|
|
36
|
+
if run_status.success?
|
|
37
|
+
Chef::Log.info 'Updating Chef info in MOTD ...'
|
|
38
|
+
delete_outdated
|
|
39
|
+
write_out(generate_message)
|
|
40
|
+
else
|
|
41
|
+
if @failure_message then write_out(failure_message) end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
34
47
|
def defaults
|
|
35
48
|
return {
|
|
36
|
-
:
|
|
37
|
-
:
|
|
49
|
+
priority: '05',
|
|
50
|
+
keep_old_entries: false,
|
|
51
|
+
failure_message: false
|
|
38
52
|
}
|
|
39
53
|
end
|
|
40
54
|
|
|
@@ -66,13 +80,10 @@ echo \"Updated resources on last run (total: #{run_status.updated_resources.leng
|
|
|
66
80
|
return msg
|
|
67
81
|
end
|
|
68
82
|
|
|
69
|
-
def
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
end
|
|
83
|
+
def failure_message
|
|
84
|
+
return <<-eos
|
|
85
|
+
#!/bin/sh
|
|
86
|
+
echo \"Node #{node.name} Chef run failed at #{Time.now.to_s} in #{run_status.elapsed_time} seconds\"
|
|
87
|
+
eos
|
|
75
88
|
end
|
|
76
|
-
|
|
77
89
|
end
|
|
78
|
-
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chef-handler-motd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: Edits MOTD at the end of a Chef run
|
|
15
15
|
email: ops@simple.com
|
|
@@ -17,6 +17,7 @@ executables: []
|
|
|
17
17
|
extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
|
19
19
|
files:
|
|
20
|
+
- chef-handler-motd-0.3.2.gem
|
|
20
21
|
- chef-handler-motd.gemspec
|
|
21
22
|
- lib/chef-handler-motd.rb
|
|
22
23
|
- LICENSE
|