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.puppetlabs.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, 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() click to toggle source
# File lib/puppet/agent/disabler.rb, line 37
def disable_message
  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?() click to toggle source
# File lib/puppet/agent/disabler.rb, line 33
def disabled?
  disable_lockfile.locked?
end
enable() click to toggle source

Let the daemon run again, freely in the filesystem.

# File lib/puppet/agent/disabler.rb, line 18
def enable
  Puppet.notice "Enabling Puppet."
  disable_lockfile.unlock
end