diff --git a/provider/service/systemd.rb b/provider/service/systemd.rb index d6c25d2..1abda4f 100644 --- a/provider/service/systemd.rb +++ b/provider/service/systemd.rb @@ -5,19 +5,25 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do commands :systemctl => "systemctl" + Facter.add(:runs_on_systemd) do + setcode do + Dir.exists? "/run/systemd/system" + end + end + if Facter.value(:osfamily).downcase == 'debian' # With multiple init systems on Debian, it is possible to have # pieces of systemd around (e.g. systemctl) but not really be # using systemd. We do not do this on other platforms as it can # cause issues when running in a chroot without /run mounted # (PUP-5577) - confine :exists => "/run/systemd/system" + confine :runs_on_systemd => :true end defaultfor :osfamily => [:archlinux] defaultfor :osfamily => :redhat, :operatingsystemmajrelease => "7" defaultfor :osfamily => :redhat, :operatingsystem => :fedora, :operatingsystemmajrelease => ["17", "18", "19", "20", "21"] - defaultfor :operatingsystem => :ubuntu, :exists => "/run/systemd/system" + defaultfor :operatingsystem => :ubuntu, :runs_on_systemd => :true def self.instances i = [] diff --git a/provider/service/upstart.rb b/provider/service/upstart.rb index cc55af2..b784430 100644 --- a/provider/service/upstart.rb +++ b/provider/service/upstart.rb @@ -11,12 +11,18 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do see . " + Facter.add(:runs_on_systemd) do + setcode do + Dir.exists? "/run/systemd/system" + end + end + confine :any => [ (Facter.value(:operatingsystem) == 'Ubuntu' and !File.exists?("/run/systemd/system")), (Facter.value(:osfamily) == 'RedHat' and Facter.value(:operatingsystemrelease) =~ /^6\./), ] - defaultfor :operatingsystem => :ubuntu, { :exists => "/run/systemd/system" } => :false + defaultfor :operatingsystem => :ubuntu, :runs_on_systemd => :false commands :start => "/sbin/start", :stop => "/sbin/stop",