Skip to content

Instantly share code, notes, and snippets.

@apenney
Created May 29, 2013 13:10
Show Gist options
  • Save apenney/5670147 to your computer and use it in GitHub Desktop.
Save apenney/5670147 to your computer and use it in GitHub Desktop.
fact to determine apache version
# 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
@jcharaoui
Copy link

Under which license are you releasing this code? I'd like to include it in our GPLv3 puppet apache module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment