summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/handler/runner.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/network/handler/runner.rb')
-rwxr-xr-xlib/puppet/network/handler/runner.rb51
1 files changed, 9 insertions, 42 deletions
diff --git a/lib/puppet/network/handler/runner.rb b/lib/puppet/network/handler/runner.rb
index c97e4791a..070cae114 100755
--- a/lib/puppet/network/handler/runner.rb
+++ b/lib/puppet/network/handler/runner.rb
@@ -1,3 +1,5 @@
+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.
@@ -13,51 +15,16 @@ class Puppet::Network::Handler
# 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::Network::Client.client(:Master).instance
-
- unless master
- raise MissingMasterError, "Could not find the master client"
- end
-
- if Puppet::Util::Pidlock.new(Puppet[:puppetdlockfile]).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 += " ignoring schedules"
- end
+ options = {}
+ options[:tags] = tags if tags
+ options[:ignoreschedules] = ignoreschedules if ignoreschedules
+ options[:background] = !fg
- Puppet.notice msg
+ runner = Puppet::Agent::Runner.new(options)
- # And then we need to tell it to run, with this extra info.
- if fg
- master.run(:tags => tags, :ignoreschedules => ignoreschedules)
- else
- Puppet.newthread do
- master.run(:tags => tags, :ignoreschedules => ignoreschedules)
- end
- end
+ runner.run
- return "success"
+ return runner.status
end
end
end