/usr/lib/ruby/1.8/mcprovision/notifier.rb is in mcollective-server-provisioner 0.0.1~git20110120-0ubuntu5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 38 | module MCProvision
class Notifier
def initialize(config)
@config = config
if @config.settings.include?("notify")
setup
end
end
def notify(msg, subject)
if @config.settings.include?("notify")
raise "No notification targets specified" unless @config.settings["notify"].include?("targets")
raise "No notification targets specified" if @config.settings["notify"]["targets"].empty?
@config.settings["notify"]["targets"].each do |recipient|
MCProvision.info("Notifying #{recipient} of new node")
raise "Could not find any instances of the '#{@config.settings['notify']['agent']}' agent" if @rpc.discover.empty?
@rpc.sendmsg(:message => msg, :subject => subject, :recipient => recipient)
end
end
end
private
def setup
agent = @config.settings["notify"]["agent"] || "angelianotify"
@rpc = rpcclient(agent)
@rpc.progress = false
# in environments with many notifiers running only speak to 1
@rpc.limit_targets = 1
@rpc.filter = Util.parse_filter(agent, @config.settings["notify"]["filter"])
end
end
end
|