From 1972d15afaf4a7abb69540d545301cd22337cd72 Mon Sep 17 00:00:00 2001 From: Sonu Saha Date: Wed, 20 Apr 2022 15:26:22 +0530 Subject: [PATCH] Issue-5809: Initial fix for service resource on amazon linux Signed-off-by: Sonu Saha --- lib/inspec/resources/service.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/inspec/resources/service.rb b/lib/inspec/resources/service.rb index 9752539d8..882ea3dba 100644 --- a/lib/inspec/resources/service.rb +++ b/lib/inspec/resources/service.rb @@ -182,11 +182,12 @@ module Inspec::Resources when "aix" SrcMstr.new(inspec) when "amazon" - if os[:release] =~ /^20\d\d/ - Upstart.new(inspec, service_ctl) - else - Systemd.new(inspec, service_ctl) - end + inspec.command("initctl").exist? ? Upstart.new(inspec, service_ctl) : Systemd.new(inspec, service_ctl) + # if os[:release] =~ /^20\d\d/ + # Upstart.new(inspec, service_ctl) + # else + # Systemd.new(inspec, service_ctl) + # end when "solaris", "smartos", "omnios", "openindiana", "opensolaris", "nexentacore" Svcs.new(inspec) when "yocto"