Skip to content

Commit 928cf67

Browse files
kajinamitmhashizume
authored andcommitted
(PUP-11433) Use systemd by default in CentOS/RHEL
Since CentOS7/RHEL7, systemd is used to manage services. This change changes the default provider in CentOS/RHEL from the old redhat provider based on init, to the systemd provider, so that we no longer need to update the provider code when adding support for a new version of CentOS/RHEL. The old redhat provider is still used for CentOS/RHEL<7 which are using init to manage services.
1 parent 97f7854 commit 928cf67

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

lib/puppet/provider/service/redhat.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
commands :chkconfig => "/sbin/chkconfig", :service => "/sbin/service"
1212

1313
defaultfor 'os.family' => :redhat
14+
defaultfor 'os.name' => :redhat, 'os.release.major' => (4..6).to_a
1415
defaultfor 'os.family' => :suse, 'os.release.major' => ["10", "11"]
1516

1617
# Remove the symlinks

lib/puppet/provider/service/systemd.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
confine :true => Puppet::FileSystem.exist?('/proc/1/comm') && Puppet::FileSystem.read('/proc/1/comm').include?('systemd')
1717

1818
defaultfor 'os.family' => [:archlinux]
19+
defaultfor 'os.name' => :redhat
1920
defaultfor 'os.family' => :redhat, 'os.release.major' => ["7", "8", "9"]
21+
notdefaultfor 'os.name' => :redhat, 'os.release.major' => (4..6).to_a # Use the "RedHat" service provider
2022
defaultfor 'os.family' => :redhat, 'os.name' => :fedora
2123
defaultfor 'os.family' => :suse
2224
defaultfor 'os.family' => :coreos

spec/unit/provider/service/redhat_spec.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
allow(Facter).to receive(:value).with('os.family').and_return('RedHat')
2020
end
2121

22-
osfamilies = [ 'RedHat' ]
23-
24-
osfamilies.each do |osfamily|
25-
it "should be the default provider on #{osfamily}" do
26-
expect(Facter).to receive(:value).with('os.family').and_return(osfamily)
22+
[4, 5, 6].each do |ver|
23+
it "should be the default provider on rhel#{ver}" do
24+
allow(Facter).to receive(:value).with('os.release.major').and_return(ver)
2725
expect(provider_class.default?).to be_truthy
2826
end
2927
end

0 commit comments

Comments
 (0)