From c3daa6fc7f4ef179413486f527f730bfc3f77f68 Mon Sep 17 00:00:00 2001 From: "david.bayer" Date: Fri, 29 Sep 2017 14:20:17 -0500 Subject: [PATCH 1/4] use upstart on centos/redhat if installed --- libraries/logstash_util.rb | 2 +- metadata.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/logstash_util.rb b/libraries/logstash_util.rb index 3461526..3832f4f 100644 --- a/libraries/logstash_util.rb +++ b/libraries/logstash_util.rb @@ -52,7 +52,7 @@ def self.determine_native_init(node) end when 'redhat', 'centos', 'scientific' if platform_major_version <= 6 - 'sysvinit' + File.exist?('/sbin/start') ? 'upstart' : 'sysvinit' else 'systemd' end diff --git a/metadata.rb b/metadata.rb index 12a5116..4920176 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,7 +6,7 @@ description 'Installs/Configures logstash' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '1.0.0' +version '1.0.1' %w(ubuntu debian redhat centos scientific amazon fedora).each do |os| supports os From b34e2b364c2c810b4dff5b942910466e14b86a4b Mon Sep 17 00:00:00 2001 From: "david.bayer" Date: Fri, 29 Sep 2017 14:52:34 -0500 Subject: [PATCH 2/4] set cent5 to sysv & 6 to upstart & fix tests --- libraries/logstash_util.rb | 6 ++++-- test/unit/spec/util_spec.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/logstash_util.rb b/libraries/logstash_util.rb index 3832f4f..0cf6bf6 100644 --- a/libraries/logstash_util.rb +++ b/libraries/logstash_util.rb @@ -51,8 +51,10 @@ def self.determine_native_init(node) 'systemd' end when 'redhat', 'centos', 'scientific' - if platform_major_version <= 6 - File.exist?('/sbin/start') ? 'upstart' : 'sysvinit' + if platform_major_version <= 5 + 'sysvinit' + elsif platform_major_version == 6 + 'upstart' else 'systemd' end diff --git a/test/unit/spec/util_spec.rb b/test/unit/spec/util_spec.rb index 0107345..913be45 100644 --- a/test/unit/spec/util_spec.rb +++ b/test/unit/spec/util_spec.rb @@ -81,7 +81,7 @@ context 'with 6' do let(:node) { { 'platform' => 'centos', 'platform_version' => '6' } } it 'returns sysvinit' do - expect(Logstash.determine_native_init(node)).to eql('sysvinit') + expect(Logstash.determine_native_init(node)).to eql('upstart') end end context 'with 7' do From 2fd490633a755b656bd2feb90691a784b9f5aed2 Mon Sep 17 00:00:00 2001 From: "david.bayer" Date: Fri, 29 Sep 2017 14:55:33 -0500 Subject: [PATCH 3/4] fix test expect --- test/unit/spec/util_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/spec/util_spec.rb b/test/unit/spec/util_spec.rb index 913be45..9295572 100644 --- a/test/unit/spec/util_spec.rb +++ b/test/unit/spec/util_spec.rb @@ -80,7 +80,7 @@ end context 'with 6' do let(:node) { { 'platform' => 'centos', 'platform_version' => '6' } } - it 'returns sysvinit' do + it 'returns upstart' do expect(Logstash.determine_native_init(node)).to eql('upstart') end end From 909279dfee79febd184734a76ab3a8d6021e7874 Mon Sep 17 00:00:00 2001 From: "david.bayer" Date: Fri, 29 Sep 2017 15:36:18 -0500 Subject: [PATCH 4/4] fix style & test --- libraries/logstash_util.rb | 6 ++---- test/unit/spec/util_spec.rb | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/logstash_util.rb b/libraries/logstash_util.rb index 0cf6bf6..3832f4f 100644 --- a/libraries/logstash_util.rb +++ b/libraries/logstash_util.rb @@ -51,10 +51,8 @@ def self.determine_native_init(node) 'systemd' end when 'redhat', 'centos', 'scientific' - if platform_major_version <= 5 - 'sysvinit' - elsif platform_major_version == 6 - 'upstart' + if platform_major_version <= 6 + File.exist?('/sbin/start') ? 'upstart' : 'sysvinit' else 'systemd' end diff --git a/test/unit/spec/util_spec.rb b/test/unit/spec/util_spec.rb index 9295572..1ae9882 100644 --- a/test/unit/spec/util_spec.rb +++ b/test/unit/spec/util_spec.rb @@ -81,6 +81,7 @@ context 'with 6' do let(:node) { { 'platform' => 'centos', 'platform_version' => '6' } } it 'returns upstart' do + allow(File).to receive(:exist?).with('/sbin/start').and_return(true) expect(Logstash.determine_native_init(node)).to eql('upstart') end end