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.
24 25 26 27 28 29 30 31 |
# File 'lib/puppet/agent/disabler.rb', line 24 def disable(msg=nil) data = {} Puppet.notice _("Disabling Puppet.") if (! msg.nil?) data[DISABLED_MESSAGE_JSON_KEY] = msg end disable_lockfile.lock(data) end |
#disable_message ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/puppet/agent/disabler.rb', line 37 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
33 34 35 |
# File 'lib/puppet/agent/disabler.rb', line 33 def disabled? disable_lockfile.locked? end |