summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2017-05-16 14:47:31 +0100
committerGitHub <noreply@github.com>2017-05-16 14:47:31 +0100
commit2e66fa91a4472821dadbc6ea87e23804d9bb5b16 (patch)
tree3a2d97a14cf238196cf53a93a588865635faeed4
parent9d948676a6647283ef73f233dcbd98a6aff00c00 (diff)
parent0c2552ed0e66a213eced4f6959e06783deb42a92 (diff)
downloadchef-2e66fa91a4472821dadbc6ea87e23804d9bb5b16.tar.gz
Merge pull request #6157 from shortdudey123/prefer_systemd_with_sysvinit_backport
Prefer Systemd with sysvinit script over Upstart for service provider
-rw-r--r--lib/chef/platform/service_helpers.rb2
-rw-r--r--spec/unit/provider_resolver_spec.rb20
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb
index 87b87d4c72..02d293449c 100644
--- a/lib/chef/platform/service_helpers.rb
+++ b/lib/chef/platform/service_helpers.rb
@@ -69,7 +69,7 @@ class Chef
configs = []
if ::File.exist?(Chef.path_to("/etc/init.d/#{service_name}"))
- configs << :initd
+ configs += [ :initd, :systemd ]
end
if ::File.exist?(Chef.path_to("/etc/init/#{service_name}.conf"))
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index ec102209ab..56bc27d075 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -192,34 +192,34 @@ describe Chef::ProviderResolver do
stub_service_providers(:debian, :invokercd, :upstart, :systemd)
end
- it "when only the SysV init script exists, it returns a Service::Debian provider" do
+ it "when both the SysV init and Systemd script exists, it returns a Service::Debian provider" do
stub_service_configs(:initd, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
- it "when both SysV and Upstart scripts exist, it returns a Service::Upstart provider" do
+ it "when SysV, Upstart, and Systemd scripts exist, it returns a Service::Systemd provider" do
stub_service_configs(:initd, :upstart, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
- it "when only the Upstart script exists, it returns a Service::Upstart provider" do
+ it "when both the Upstart and Systemd scripts exists, it returns a Service::Systemd provider" do
stub_service_configs(:upstart, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
- it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
+ it "when both do not exist, it calls the old style provider resolver and returns a Systemd Provider" do
stub_service_configs(:systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
- it "when only the SysV init script exists, it returns a Service::Debian provider" do
+ it "when only the SysV init script exists, it returns a Service::Systemd provider" do
stub_service_configs(:initd)
- expect(resolved_provider).to eql(Chef::Provider::Service::Debian)
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
- it "when both SysV and Upstart scripts exist, it returns a Service::Upstart provider" do
+ it "when both SysV and Upstart scripts exist, it returns a Service::Systemd provider" do
stub_service_configs(:initd, :upstart)
- expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
it "when only the Upstart script exists, it returns a Service::Upstart provider" do
@@ -227,7 +227,7 @@ describe Chef::ProviderResolver do
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
end
- it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
+ it "when both do not exist, it calls the old style provider resolver and returns a Systemd Provider" do
stub_service_configs
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
@@ -410,7 +410,7 @@ describe Chef::ProviderResolver do
stub_service_providers(:debian, :invokercd, :upstart, :systemd)
stub_service_configs(:initd, :upstart)
mock_shellout_command("/bin/systemctl list-unit-files", exitstatus: 1)
- expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
end