{"record":{"id":"ef4f7d856a90c925","repo":"puppetlabs/puppet","slug":"could-not-disable-name-detail","errorCode":null,"errorMessage":"Could not disable #{name}: #{detail}","messagePattern":"Could not disable #(.+?): #(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/service/redhat.rb","lineNumber":26,"sourceCode":"\n  \"\n\n  commands :chkconfig => \"/sbin/chkconfig\", :service => \"/sbin/service\"\n\n  defaultfor 'os.name' => :amazon, 'os.release.major' => %w[2017 2018]\n  defaultfor 'os.name' => :redhat, 'os.release.major' => (4..6).to_a\n  defaultfor 'os.family' => :suse, 'os.release.major' => %w[10 11]\n\n  # Remove the symlinks\n  def disable\n    # The off method operates on run levels 2,3,4 and 5 by default We ensure\n    # all run levels are turned off because the reset method may turn on the\n    # service in run levels 0, 1 and/or 6\n    # We're not using --del here because we want to disable the service only,\n    # and --del removes the service from chkconfig management\n    chkconfig(\"--level\", \"0123456\", @resource[:name], :off)\n  rescue Puppet::ExecutionFailure => detail\n    raise Puppet::Error, \"Could not disable #{name}: #{detail}\", detail.backtrace\n  end\n\n  def enabled?\n    name = @resource[:name]\n\n    begin\n      output = chkconfig name\n    rescue Puppet::ExecutionFailure\n      return :false\n    end\n\n    # For Suse OS family, chkconfig returns 0 even if the service is disabled or non-existent\n    # Therefore, check the output for '<name>  on' (or '<name>  B for boot services)\n    # to see if it is enabled\n    return :false unless Puppet.runtime[:facter].value('os.family') != 'Suse' || output =~ /^#{name}\\s+(on|B)$/\n\n    :true\n  end","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/service/redhat.rb#L8-L44","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run chkconfig --level 0123456 <name> off by hand and read its output","Check registration state: chkconfig --list <name>","On EL7+, switch to the systemd provider instead of forcing redhat","If the script is locally managed, add the chkconfig header lines it needs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# pre-flight for a disable\nchkconfig --list \"${name}\" >/dev/null 2>&1 || echo \"not chkconfig-registered — disable will fail\"\ntest -x /sbin/chkconfig || echo \"chkconfig missing — wrong provider for this OS?\"","typeGuard":null,"tryCatchPattern":"begin\n  provider.disable\nrescue Puppet::Error => e\n  # detail carries chkconfig's message; do not blanket-rescue in manifests\n  warn \"chkconfig off failed for #{name}: #{e.message}\"\nend","preventionTips":["Scope provider => 'redhat' to EL4-6/Suse 10-11 via facts; use systemd provider on EL7+","Verify chkconfig --list <name> works in host acceptance checks before managing enable/disable","For local init scripts, always include the # chkconfig: header so registration paths stay valid"],"tags":["puppet","redhat","chkconfig","service","disable"],"backgroundTag":"command-execution-failure","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}