Module: Puppet::Agent::Disabler
- Included in:
- Puppet::Agent
- Defined in:
- lib/puppet/agent/disabler.rb
Overview
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
Constant Summary collapse
- DISABLED_MESSAGE_JSON_KEY =
"disabled_message"
Instance Method Summary collapse
-
#disable(msg = nil) ⇒ Object
Stop the daemon from making any catalog runs.
- #disable_message ⇒ Object
- #disabled? ⇒ Boolean
-
#enable ⇒ Object
Let the daemon run again, freely in the filesystem.
Instance Method Details
#disable(msg = nil) ⇒ Object
Stop the daemon from making any catalog runs.
26 27 28 29 30 31 32 33 |
# File 'lib/puppet/agent/disabler.rb', line 26 def disable(msg = nil) data = {} Puppet.notice _("Disabling Puppet.") unless msg.nil? data[DISABLED_MESSAGE_JSON_KEY] = msg end disable_lockfile.lock(data) end |
#disable_message ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/puppet/agent/disabler.rb', line 39 def data = disable_lockfile.lock_data return nil if data.nil? if data.has_key?(DISABLED_MESSAGE_JSON_KEY) return data[DISABLED_MESSAGE_JSON_KEY] end nil end |
#disabled? ⇒ Boolean
35 36 37 |
# File 'lib/puppet/agent/disabler.rb', line 35 def disabled? disable_lockfile.locked? end |