blob: 985ed2d3b0d53a1cd7128c62add3404ef08f716d (
plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
module Puppet
class Server
class MissingMasterError < RuntimeError # Cannot find the master client
end
# A simple server for triggering a new run on a Puppet client.
class Runner < Handler
@interface = XMLRPC::Service::Interface.new("puppetrunner") { |iface|
iface.add_method("string run(string, string)")
}
# Run the client configuration right now, optionally specifying
# tags and whether to ignore schedules
def run(tags = nil, ignoreschedules = false, fg = true, client = nil, clientip = nil)
# We need to retrieve the client
master = Puppet::Client::MasterClient.instance
unless master
raise MissingMasterError, "Could not find the master client"
end
if master.locked?
Puppet.notice "Could not trigger run; already running"
return "running"
end
if tags == ""
tags = nil
end
if ignoreschedules == ""
ignoreschedules == nil
end
msg = ""
if client
msg = "%s(%s) " % [client, clientip]
end
msg += "triggered run" %
if tags
msg += " with tags %s" % tags
end
if ignoreschedules
msg += " without schedules"
end
Puppet.notice msg
# And then we need to tell it to run, with this extra info.
if fg
master.run(tags, ignoreschedules)
else
Puppet.newthread do
master.run(tags, ignoreschedules)
end
end
return "success"
end
end
end
end
# $Id$
|