Created
May 29, 2013 13:10
-
-
Save apenney/5670147 to your computer and use it in GitHub Desktop.
fact to determine apache version
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
# determine the version of apache installed | |
def parse_version(version_string) | |
version = "" | |
version_string.each_line do |line| | |
if line.match(/^Server version/) | |
version = line.scan(/Apache\/(.*) /) | |
end | |
end | |
return version | |
end | |
Facter.add('apache_version') do | |
setcode do | |
case Facter.value('osfamily') | |
when /RedHat/ | |
if File.exists?('/usr/sbin/httpd') | |
version = parse_version(%x(/usr/sbin/httpd -v)) | |
end | |
when /Debian/ | |
if File.exists?('/usr/sbin/apache2') | |
version = parse_version(%x(/usr/sbin/apache2 -v)) | |
end | |
else | |
version = 'undef' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Under which license are you releasing this code? I'd like to include it in our GPLv3 puppet apache module.