puppetlabs/puppet · error · Puppet::Error

Could not disable #{name}: #{detail}

Error message

Could not disable #{name}: #{detail}

What it means

The redhat service provider disables a service with chkconfig --level 0123456 <name> off (deliberately not --del, which would remove chkconfig management) and converts any Puppet::ExecutionFailure into Puppet::Error with the failure detail. The provider is defaultfor redhat 4-6 and suse 10/11, reflecting chkconfig-era systems.

Source

Thrown at lib/puppet/provider/service/redhat.rb:26

  "

  commands :chkconfig => "/sbin/chkconfig", :service => "/sbin/service"

  defaultfor 'os.name' => :amazon, 'os.release.major' => %w[2017 2018]
  defaultfor 'os.name' => :redhat, 'os.release.major' => (4..6).to_a
  defaultfor 'os.family' => :suse, 'os.release.major' => %w[10 11]

  # Remove the symlinks
  def disable
    # The off method operates on run levels 2,3,4 and 5 by default We ensure
    # all run levels are turned off because the reset method may turn on the
    # service in run levels 0, 1 and/or 6
    # We're not using --del here because we want to disable the service only,
    # and --del removes the service from chkconfig management
    chkconfig("--level", "0123456", @resource[:name], :off)
  rescue Puppet::ExecutionFailure => detail
    raise Puppet::Error, "Could not disable #{name}: #{detail}", detail.backtrace
  end

  def enabled?
    name = @resource[:name]

    begin
      output = chkconfig name
    rescue Puppet::ExecutionFailure
      return :false
    end

    # For Suse OS family, chkconfig returns 0 even if the service is disabled or non-existent
    # Therefore, check the output for '<name>  on' (or '<name>  B for boot services)
    # to see if it is enabled
    return :false unless Puppet.runtime[:facter].value('os.family') != 'Suse' || output =~ /^#{name}\s+(on|B)$/

    :true
  end

View on GitHub (pinned to e227c27540)

Solutions

  1. Run chkconfig --level 0123456 <name> off by hand and read its output
  2. Check registration state: chkconfig --list <name>
  3. On EL7+, switch to the systemd provider instead of forcing redhat
  4. If the script is locally managed, add the chkconfig header lines it needs
Defensive patterns

Strategy: validation

Validate before calling

# pre-flight for a disable
chkconfig --list "${name}" >/dev/null 2>&1 || echo "not chkconfig-registered — disable will fail"
test -x /sbin/chkconfig || echo "chkconfig missing — wrong provider for this OS?"

Try / catch

begin
  provider.disable
rescue Puppet::Error => e
  # detail carries chkconfig's message; do not blanket-rescue in manifests
  warn "chkconfig off failed for #{name}: #{e.message}"
end

Prevention

When it happens

Trigger: disable runs on a host where the chkconfig call fails: service never registered with chkconfig, /sbin/chkconfig absent (systemd-only EL7+ box with provider forced to redhat), init script missing its chkconfig header, or name not matching a registered script.

Common situations: Forcing provider => 'redhat' on EL7+/EL8 hosts where chkconfig semantics differ; packages shipping init scripts without the required ### BEGIN INIT INFO/# chkconfig: block; catalogs written for RHEL6 reused on newer releases.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/ef4f7d856a90c925. Report an issue: GitHub.