-
Notifications
You must be signed in to change notification settings - Fork 2
/
puppet-growl.rb
executable file
·30 lines (24 loc) · 977 Bytes
/
puppet-growl.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/ruby -w
require 'rubygems'
require 'em-dir-watcher'
require 'ruby-growl'
# Growl host to send notifications to, make sure to allow the following in Growl preferences:
# Listen for incoming connections, allow remote application registeration
host = "127.0.0.1"
# Dir to watch puppet manifests, could be your puppet manifests under development
dir = "/etc/puppet"
EM.run {
dw = EMDirWatcher.watch File.expand_path(dir), :include_only => ['*.pp'] do |paths|
paths.each do |path|
full_path = File.join(dir, path)
puts "Full Path: #{full_path}"
result = `puppet --parseonly #{full_path}`.chomp
g = Growl.new host, "ruby-growl", ["ruby-growl Notification"]
if result.any?
g.notify "ruby-growl Notification", "Puppet", "Syntax Problem, Manifest #{full_path}: #{result}"
else
g.notify "ruby-growl Notification", "Puppet", "Manifest #{full_path}: Syntax OK"
end
end
end
}