{"record":{"id":"8381a9461969849c","repo":"puppetlabs/puppet","slug":"could-not-enable-name-detail","errorCode":null,"errorMessage":"Could not enable #{name}: #{detail}","messagePattern":"Could not enable #(.+?): #(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/service/redhat.rb","lineNumber":52,"sourceCode":"    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\n\n  # Don't support them specifying runlevels; always use the runlevels\n  # in the init scripts.\n  def enable\n    chkconfig(\"--add\", @resource[:name])\n    chkconfig(@resource[:name], :on)\n  rescue Puppet::ExecutionFailure => detail\n    raise Puppet::Error, \"Could not enable #{name}: #{detail}\", detail.backtrace\n  end\n\n  def initscript\n    raise Puppet::Error, \"Do not directly call the init script for '#{@resource[:name]}'; use 'service' instead\"\n  end\n\n  # use hasstatus=>true when its set for the provider.\n  def statuscmd\n    ((@resource.provider.get(:hasstatus) == true) || (@resource[:hasstatus] == :true)) && [command(:service), @resource[:name], \"status\"]\n  end\n\n  def restartcmd\n    (@resource[:hasrestart] == :true) && [command(:service), @resource[:name], \"restart\"]\n  end\n\n  def startcmd\n    [command(:service), @resource[:name], \"start\"]\n  end","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/service/redhat.rb#L34-L70","documentation":"The redhat provider's enable performs two chkconfig calls — chkconfig --add <name> then chkconfig <name> on — and either failing raises Puppet::Error with the execution detail. --add registers the script found in /etc/init.d; it fails outright when that script is missing or lacks the chkconfig metadata chkconfig needs.","triggerScenarios":"enable on a service whose /etc/init.d/<name> script does not exist (package not yet installed), exists but has no '# chkconfig:' runlevel/start/stop header, or when chkconfig itself exits non-zero (read-only /etc, SELinux denials).","commonSituations":"Missing Package -> Service ordering so enable precedes installation; hand-dropped init scripts without chkconfig headers; migrating RHEL6 catalogs to hosts where the daemon moved to native systemd units.","solutions":["Run chkconfig --add <name> manually; its stderr names the exact problem (usually 'service <name> does not support chkconfig')","Add the chkconfig header to the init script: # chkconfig: 2345 20 80 plus description","Order the package before the service: Package['<pkg>'] -> Service['<name>']","Prefer the systemd provider on releases where the unit is native"],"exampleFix":"# before (script at /etc/init.d/myapp without a chkconfig header)\nservice { 'myapp': ensure => running, enable => true, provider => 'redhat' }\n\n# after: header present, registration succeeds\n# /etc/init.d/myapp:\n# chkconfig: 2345 20 80\n# description: myapp daemon\nservice { 'myapp': ensure => running, enable => true, provider => 'redhat' }","handlingStrategy":"validation","validationCode":"# enable needs a registered, header-bearing init script\ntest -x \"/etc/init.d/${name}\" && grep -q '^# chkconfig:' \"/etc/init.d/${name}\" \\\n  || echo \"${name}: missing script or chkconfig header — enable will fail\"","typeGuard":null,"tryCatchPattern":"begin\n  provider.enable\nrescue Puppet::Error => e\n  warn \"chkconfig add/on failed for #{name}: run 'chkconfig --add #{name}' manually to see why\"\nend","preventionTips":["Enforce Package -> Service ordering in all service profiles","Lint shipped init scripts for the chkconfig header in CI","On EL7+ hosts, map legacy names to systemd units in your data instead of forcing the redhat provider"],"tags":["puppet","redhat","chkconfig","service","enable"],"backgroundTag":"command-execution-failure","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}