Created
October 1, 2015 17:13
-
-
Save asasfu/e00eaf76f37141fca083 to your computer and use it in GitHub Desktop.
A way to better support service_provider_fact
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Puppet::Parser::Functions | |
newfunction(:service_provider_func, :type => :rvalue, :doc => <<-EOS | |
Returns the default service provider for the system overridden by any parent class | |
that has Service { provider => $my_service_provider } specified to cause an override. | |
This is useful when we actually need to know the clients service provider and allow them | |
to also override it in case they decide they need a different one due to puppet not picking | |
the right one for their new or old Operating System. | |
Example: | |
Centos 7(systemd) | |
{ | |
$var = service_provider_func() | |
} | |
>>> $var prints 'systemd' | |
{ | |
Service { | |
provider => 'upstart' | |
} | |
$var = service_provider_func() | |
} | |
>>> $var prints 'upstart' | |
EOS | |
) do |args| | |
override = self.lookupdefaults('Service')[:provider].value | |
override = lookupvar('service_provider') if override.nil? || override.empty? | |
return override | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If it's a file resource of the type
file { /etc/init.d/bla: }
then you don't really need an override at all, just drop your own withfile { '/etc/systemd/...: }