-
Notifications
You must be signed in to change notification settings - Fork 289
/
Copy pathsensu_gem.rb
30 lines (24 loc) · 1.01 KB
/
sensu_gem.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
require 'puppet/provider/package'
require 'uri'
# Ruby gems support.
Puppet::Type.type(:package).provide :sensu_gem, :parent => :gem do
desc "Sensu Embedded Ruby Gem support. If a URL is passed via `source`, then
that URL is used as the remote gem repository; if a source is present but is
not a valid URL, it will be interpreted as the path to a local gem file. If
source is not present at all, the gem will be installed from the default gem
repositories."
has_feature :versionable, :install_options
commands :gemcmd =>
if RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|winse|emx/
"#{ENV['SYSTEMDRIVE']}\\opt\\sensu\\embedded\\bin\\gem.cmd"
else
"/opt/sensu/embedded/bin/gem"
end
def uninstall
command = [command(:gemcmd), "uninstall"]
command << "-x" << "-a" << resource[:name]
output = execute(command)
# Apparently some stupid gem versions don't exit non-0 on failure
self.fail "Could not uninstall: #{output.chomp}" if output.include?("ERROR")
end
end