Promote Sabayon to a fully supported OS with package and service resource support

This commit is contained in:
2011-05-23 08:03:33 +01:00
parent 42b786e9ad
commit 98bf0e8ca0
3 changed files with 66 additions and 3 deletions

View File

@@ -0,0 +1,13 @@
require 'facter/lsb'
Facter.add(:operatingsystem) do
confine :kernel => :linux
confine :has_entropy => true
setcode do
if FileTest.exists?("/etc/sabayon-release")
"Sabayon"
end
end
end

View File

@@ -11,9 +11,9 @@ Puppet::Type.type(:package).provide :entropy, :parent => Puppet::Provider::Packa
commands :equo => "/usr/bin/equo"
#confine :operatingsystem => [ :gentoo, :sabayon ]
defaultfor :has_entropy => true
confine :operatingsystem => :sabayon
defaultfor :operatingsystem => :sabayon
def self.instances
result_format = /^(\S+)\/(\S+)-([\.\d]+(?:_(?:alpha|beta|pre|rc|p)\d+)?(?:-r\d+)?)$/

View File

@@ -0,0 +1,50 @@
# Manage gentoo services. Start/stop is the same as InitSvc, but enable/disable
# is special.
Puppet::Type.type(:service).provide :gentoo, :parent => :init do
desc "Gentoo's form of `init`-style service management.
Uses `rc-update` for service enabling and disabling.
"
commands :update => "/sbin/rc-update"
confine :operatingsystem => [ :gentoo, :sabayon ]
defaultfor :operatingsystem => [ :gentoo, :sabayon ]
def self.defpath
superclass.defpath
end
def disable
output = update :del, @resource[:name], :default
rescue Puppet::ExecutionFailure
raise Puppet::Error, "Could not disable #{self.name}: #{output}"
end
def enabled?
begin
output = update :show
rescue Puppet::ExecutionFailure
return :false
end
line = output.split(/\n/).find { |l| l.include?(@resource[:name]) }
return :false unless line
# If it's enabled then it will print output showing service | runlevel
if output =~ /^\s*#{@resource[:name]}\s*\|\s*(boot|default)/
return :true
else
return :false
end
end
def enable
output = update :add, @resource[:name], :default
rescue Puppet::ExecutionFailure
raise Puppet::Error, "Could not enable #{self.name}: #{output}"
end
end