-
-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix broken dependency to puppetlabs/apache module
* Copy apache_version from puppetlabs/apache v8.x module. Puppetlabs removed apache_version with the v9 release of the apache module. apache_version was used to distiguish between the needed settings.
- Loading branch information
Phil Friderici
committed
Mar 28, 2023
1 parent
b7248fb
commit 95f5c20
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
Facter.add(:apache_version) do | ||
confine kernel: ['FreeBSD', 'Linux'] | ||
setcode do | ||
apache_version = nil | ||
|
||
if Facter::Core::Execution.which('httpd') | ||
apache_version = Facter::Core::Execution.execute('httpd -V 2>&1') | ||
Facter.debug "Matching httpd '#{apache_version}'" | ||
elsif Facter::Core::Execution.which('apache2') | ||
apache_version = Facter::Core::Execution.execute('apache2 -V 2>&1') | ||
Facter.debug "Matching apache2 '#{apache_version}'" | ||
elsif Facter::Core::Execution.which('apachectl') | ||
apache_version = Facter::Core::Execution.execute('apachectl -v 2>&1') | ||
Facter.debug "Matching apachectl '#{apache_version}'" | ||
elsif Facter::Core::Execution.which('apache2ctl') | ||
apache_version = Facter::Core::Execution.execute('apache2ctl -v 2>&1') | ||
Facter.debug "Matching apache2ctl '#{apache_version}'" | ||
end | ||
|
||
unless apache_version.nil? | ||
match = %r{^Server version: Apache\/(\d+.\d+(.\d+)?)}.match(apache_version) | ||
unless match.nil? | ||
match[1] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe Facter::Util::Fact do | ||
before(:each) do | ||
Facter.clear | ||
end | ||
|
||
describe 'apache_version' do | ||
context 'with value' do | ||
before :each do | ||
Facter.fact(:kernel).stubs(:value).returns('Linux') | ||
Facter::Core::Execution.stubs(:which).with('httpd').returns(true) | ||
Facter::Core::Execution.stubs(:execute).with('httpd -V 2>&1').returns('Server version: Apache/2.4.16 (Unix)\nServer built: Jul 31 2015 15:53:26') | ||
end | ||
|
||
it 'should return the correct version' do | ||
expect(Facter.fact(:apache_version).value).to eq('2.4.16') | ||
end | ||
end | ||
end | ||
|
||
describe 'apache_version with empty OS' do | ||
context 'with value' do | ||
before :each do | ||
Facter.fact(:kernel).stubs(:value).returns('Linux') | ||
Facter::Core::Execution.stubs(:which).with('httpd').returns(true) | ||
Facter::Core::Execution.stubs(:execute).with('httpd -V 2>&1').returns('Server version: Apache/2.4.6 ()\nServer built: Nov 21 2015 05:34:59') | ||
end | ||
|
||
it 'should return the correct version' do | ||
expect(Facter.fact(:apache_version).value).to eq('2.4.6') | ||
end | ||
end | ||
end | ||
end |