summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/handler/runner.rb
blob: 070cae1148727e89ee1a10f236b066bff9712cd5 (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
require 'puppet/agent/runner'

class Puppet::Network::Handler
    class MissingMasterError < RuntimeError; end # Cannot find the master client
    # A simple server for triggering a new run on a Puppet client.
    class Runner < Handler
        desc "An interface for triggering client configuration runs."

        @interface = XMLRPC::Service::Interface.new("puppetrunner") { |iface|
            iface.add_method("string run(string, string)")
        }

        side :client

        # 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)
            options = {}
            options[:tags] = tags if tags
            options[:ignoreschedules] = ignoreschedules if ignoreschedules
            options[:background] = !fg

            runner = Puppet::Agent::Runner.new(options)

            runner.run

            return runner.status
        end
    end
end