Skip to content

Commit 04b01e2

Browse files
committed
Correct Red Hat service providers
SystemD has been the default init system for Red Hat Enterprise Linux and its derivatives since RHEL 7 was released in 2014. In 928cf67, we attempted to reflect this in Puppet's service providers. However, this change did not have the desired effect as the RedHat service provider was still specified as the default for systems with the os.family fact of "redhat." Tests relating to services started failing after 928cf67. I do not believe that this change will have any undesired effects on Red Hat derivatives like Alma or Rocky because those distributions also use SystemD as their init system and use the same versioning scheme as upstream.
1 parent 49d74c9 commit 04b01e2

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

lib/puppet/provider/service/redhat.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
commands :chkconfig => "/sbin/chkconfig", :service => "/sbin/service"
1212

13-
defaultfor 'os.family' => :redhat
13+
defaultfor 'os.name' => :amazon, 'os.release.major' => ["2017", "2018"]
1414
defaultfor 'os.name' => :redhat, 'os.release.major' => (4..6).to_a
1515
defaultfor 'os.family' => :suse, 'os.release.major' => ["10", "11"]
1616

lib/puppet/provider/service/systemd.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
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
20-
defaultfor 'os.family' => :redhat, 'os.release.major' => ["7", "8", "9"]
19+
defaultfor 'os.family' => :redhat
2120
notdefaultfor 'os.name' => :redhat, 'os.release.major' => (4..6).to_a # Use the "RedHat" service provider
2221
defaultfor 'os.family' => :redhat, 'os.name' => :fedora
2322
defaultfor 'os.family' => :suse
2423
defaultfor 'os.family' => :coreos
2524
defaultfor 'os.family' => :gentoo
25+
notdefaultfor 'os.name' => :amazon, 'os.release.major' => ["2017", "2018"]
2626
defaultfor 'os.name' => :amazon, 'os.release.major' => ["2", "2023"]
2727
defaultfor 'os.name' => :debian
2828
notdefaultfor 'os.name' => :debian, 'os.release.major' => ["5", "6", "7"] # These are using the "debian" method

spec/unit/provider/service/redhat_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
[4, 5, 6].each do |ver|
2323
it "should be the default provider on rhel#{ver}" do
24+
allow(Facter).to receive(:value).with('os.name').and_return(:redhat)
2425
allow(Facter).to receive(:value).with('os.release.major').and_return(ver)
2526
expect(provider_class.default?).to be_truthy
2627
end

0 commit comments

Comments
 (0)