Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

For issue http://projects.puppetlabs.com/issues/15192 #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions agent/puppetd/agent/puppetd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ def runonce_background
cmd << "--splaylimit" << @splaytime << "--splay"
end
end

if request[:noop]
cmd << "--noop"
end

if request[:nonoop]
cmd << "--no-noop"
end

cmd = cmd.join(" ")

Expand Down
33 changes: 31 additions & 2 deletions agent/puppetd/application/puppetd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ class MCollective::Application::Puppetd<MCollective::Application
:description => "Force the puppet run to happen immediately without splay",
:arguments => ["--force", "-f"],
:type => :bool

option :noop,
:description => "Run the puppet in noop mode",
:arguments => ["--noop"],
:type => :bool

option :nonoop,
:description => "Run the puppet in no-noop mode",
:arguments => ["--no-noop"],
:type => :bool

def post_option_parser(configuration)
if ARGV.length >= 1
Expand Down Expand Up @@ -76,6 +86,16 @@ def main
hosts = mc.discover.sort
log("Found #{hosts.size} hosts")

if configuration[:noop]
parameters = { :forcerun => true, :noop => configuration[:noop] }
else
if configuration[:nonoop]
parameters = { :forcerun => true, :nonoop => configuration[:nonoop] }
else
parameters = { :forcerun => true }
end
end

# For all hosts:
# - check for concurrent runs, wait till its below threshold
# - do a run on the single host, regardless of if its already running
Expand All @@ -84,7 +104,7 @@ def main
hosts.each do |host|
running = waitfor(configuration[:concurrency], mc)
log("Running #{host}, concurrency is #{running}")
result = mc.custom_request("runonce", {:forcerun => true}, host, {"identity" => host})
result = mc.custom_request("runonce", parameters, host, {"identity" => host})

begin
log("#{host} schedule status: #{result[0][:statusmsg]}")
Expand All @@ -100,7 +120,16 @@ def main
end

when "runonce"
printrpc mc.runonce(:forcerun => configuration[:force])
if configuration[:noop]
parameters = { :forcerun => configuration[:force],
:noop => configuration[:noop] }
else
if configuration[:nonoop]
parameters = { :forcerun => configuration[:force],
:nonoop => configuration[:nonoop] }
end
end
printrpc mc.runonce(parameters)

when "status"
mc.send(configuration[:command]).each do |node|
Expand Down