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 24 def disable(msg=nil) 25 data = {} 26 Puppet.notice _("Disabling Puppet.") 27 if (! msg.nil?) 28 data[DISABLED_MESSAGE_JSON_KEY] = msg 29 end 30 disable_lockfile.lock(data) 31 end
disable_message()
click to toggle source
# File lib/puppet/agent/disabler.rb 37 def disable_message 38 data = disable_lockfile.lock_data 39 return nil if data.nil? 40 if data.has_key?(DISABLED_MESSAGE_JSON_KEY) 41 return data[DISABLED_MESSAGE_JSON_KEY] 42 end 43 nil 44 end
disabled?()
click to toggle source
# File lib/puppet/agent/disabler.rb 33 def disabled? 34 disable_lockfile.locked? 35 end
enable()
click to toggle source
Let the daemon run again, freely in the filesystem.
# File lib/puppet/agent/disabler.rb 18 def enable 19 Puppet.notice _("Enabling Puppet.") 20 disable_lockfile.unlock 21 end
Private Instance Methods
disable_lockfile()
click to toggle source
# File lib/puppet/agent/disabler.rb 47 def disable_lockfile 48 @disable_lockfile ||= Puppet::Util::JsonLockfile.new(Puppet[:agent_disabled_lockfile]) 49 50 @disable_lockfile 51 end