Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f34d3c2
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Puppet-Growl | ||
|
||
Automatic syntax checking for your puppet manifests, instant notifications to your desktop using Growl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} |