[Pkg-sysvinit-devel] Bug#705254: is-enabled, the puppet side.

Mathieu Parent math.parent at gmail.com
Thu May 7 12:17:07 UTC 2015


Hello,

Note that Puppet has the following code to test is a service is enabled:

  def enabled?
    # TODO: Replace system call when Puppet::Util::Execution.execute
gives us a way
    # to determine exit status.  http://projects.reductivelabs.com/issues/2538
    system("/usr/sbin/invoke-rc.d", "--quiet", "--query",
@resource[:name], "start")

    # 104 is the exit status when you query start an enabled service.
    # 106 is the exit status when the policy layer supplies a fallback action
    # See x-man-page://invoke-rc.d
    if [104, 106].include?($CHILD_STATUS.exitstatus)
      return :true
    elsif [101, 105].include?($CHILD_STATUS.exitstatus)
      # 101 is action not allowed, which means we have to do the check manually.
      # 105 is unknown, which generally means the iniscript does not
support query
      # The debian policy states that the initscript should support
methods of query
      # For those that do not, peform the checks manually
      # http://www.debian.org/doc/debian-policy/ch-opersys.html
      if get_start_link_count >= 4
        return :true
      else
        return :false
      end
    else
      return :false
    end
  end

I.E: this is more the policy POV. Isn't this sufficient?

-- 
Mathieu

Ref: https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/service/debian.rb#L31



More information about the Pkg-sysvinit-devel mailing list