module Puppet::Agent::Disabler

This module is responsible for encapsulating the logic for

"disabling" the puppet agent during a run; in other words,
keeping track of enough state to answer the question
"has the puppet agent been administratively disabled?"

The implementation involves writing a lockfile with JSON

contents, and is considered part of the public Puppet API
because it used by external tools such as mcollective.

For more information, please see docs on the website.

http://links.puppet.com/agent_lockfiles

Constants

DISABLED_MESSAGE_JSON_KEY

Public Instance Methods

disable(msg=nil) click to toggle source

Stop the daemon from making any catalog runs.

   # File lib/puppet/agent/disabler.rb
25 def disable(msg=nil)
26   data = {}
27   Puppet.notice _("Disabling Puppet.")
28   if (! msg.nil?)
29     data[DISABLED_MESSAGE_JSON_KEY] = msg
30   end
31   disable_lockfile.lock(data)
32 end
disable_message() click to toggle source
   # File lib/puppet/agent/disabler.rb
38 def disable_message
39   data = disable_lockfile.lock_data
40   return nil if data.nil?
41   if data.has_key?(DISABLED_MESSAGE_JSON_KEY)
42     return data[DISABLED_MESSAGE_JSON_KEY]
43   end
44   nil
45 end
disabled?() click to toggle source
   # File lib/puppet/agent/disabler.rb
34 def disabled?
35   disable_lockfile.locked?
36 end
enable() click to toggle source

Let the daemon run again, freely in the filesystem.

   # File lib/puppet/agent/disabler.rb
19 def enable
20   Puppet.notice _("Enabling Puppet.")
21   disable_lockfile.unlock
22 end

Private Instance Methods

disable_lockfile() click to toggle source
   # File lib/puppet/agent/disabler.rb
48 def disable_lockfile
49   @disable_lockfile ||= Puppet::Util::JsonLockfile.new(Puppet[:agent_disabled_lockfile])
50 
51   @disable_lockfile
52 end