From 81029274e2f90f53d6f9a6def1732747871a00f7 Mon Sep 17 00:00:00 2001 From: Satish Puranam Date: Wed, 13 Apr 2016 18:24:26 -0400 Subject: [PATCH 1/3] Add support suse 11 to service resource --- lib/resources/service.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/resources/service.rb b/lib/resources/service.rb index 231fa9b55..5908dd332 100644 --- a/lib/resources/service.rb +++ b/lib/resources/service.rb @@ -135,8 +135,15 @@ module Inspec::Resources WindowsSrv.new(inspec) elsif %w{freebsd}.include?(family) BSDInit.new(inspec, service_ctl) - elsif %w{arch opensuse}.include?(family) + elsif %w{arch}.include?(family) Systemd.new(inspec, service_ctl) + elsif %w{suse opensuse}.include?(family) + version = inspec.os[:release].to_i + if (%w{ suse opensuse }.include?(family) && version >= 12) + Systemd.new(inspec, service_ctl) + else + SysV.new(inspec, service_ctl || '/sbin/service') + end elsif %w{aix}.include?(family) SrcMstr.new(inspec) elsif %w{amazon}.include?(family) From b0bc88f63733d7fb0b2ba61e514f12d9f57ca611 Mon Sep 17 00:00:00 2001 From: Satish Puranam Date: Wed, 13 Apr 2016 19:08:14 -0400 Subject: [PATCH 2/3] Cleanup, remove redundant checking of os family --- lib/resources/service.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/resources/service.rb b/lib/resources/service.rb index 5908dd332..956b0ac59 100644 --- a/lib/resources/service.rb +++ b/lib/resources/service.rb @@ -138,8 +138,7 @@ module Inspec::Resources elsif %w{arch}.include?(family) Systemd.new(inspec, service_ctl) elsif %w{suse opensuse}.include?(family) - version = inspec.os[:release].to_i - if (%w{ suse opensuse }.include?(family) && version >= 12) + if (inspec.os[:release].to_i >= 12) Systemd.new(inspec, service_ctl) else SysV.new(inspec, service_ctl || '/sbin/service') From 07315ce5d2efc7c6e10fb99ccdeb7a0dd196d426 Mon Sep 17 00:00:00 2001 From: Satish Puranam Date: Thu, 14 Apr 2016 13:39:03 -0400 Subject: [PATCH 3/3] Cleanup code meet lint guidelines --- lib/resources/service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/resources/service.rb b/lib/resources/service.rb index 956b0ac59..e71836b50 100644 --- a/lib/resources/service.rb +++ b/lib/resources/service.rb @@ -94,7 +94,7 @@ module Inspec::Resources return skip_resource 'The `service` resource is not supported on your OS yet.' if @service_mgmt.nil? end - def select_service_mgmt # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity + def select_service_mgmt # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength os = inspec.os family = os[:family] @@ -138,7 +138,7 @@ module Inspec::Resources elsif %w{arch}.include?(family) Systemd.new(inspec, service_ctl) elsif %w{suse opensuse}.include?(family) - if (inspec.os[:release].to_i >= 12) + if inspec.os[:release].to_i >= 12 Systemd.new(inspec, service_ctl) else SysV.new(inspec, service_ctl || '/sbin/service')