File: //var/lib/puppet/lib/facter/apache.rb
Facter.add("apache") do
setcode do
result = "false"
# A bunch of boxes have shit apache installs with non-working, leftover apachectl's,
# skipping /usr/sbin/apachectl for the time being.
# We could also fix this later by correcting /usr/sbin/apachectl (maybe)
#if FileTest.exists?("/usr/sbin/apachectl")
# result = "true"
if FileTest.exists?("/usr/local/apache")
result = "true"
elsif FileTest.exists?("/usr/local/apache2")
result = "true"
end
result
end
end
Facter.add("apache_dir") do
confine :apache => :true
setcode do
result = "false"
#if FileTest.exists?("/usr/sbin/apachectl")
# result = %x{/usr/sbin/apachectl -V | grep HTTPD_ROOT | awk -F \\" \{'print $2'\}}.chomp
if FileTest.exists?("/usr/local/apache/bin/httpd")
output = %x{/usr/local/apache/bin/httpd -V | grep HTTPD_ROOT | cut -d \\" -f2}.chomp
result = output
elsif FileTest.exists?("/usr/local/apache2/bin/httpd")
output = %x{/usr/local/apache2/bin/httpd -V | grep HTTPD_ROOT | cut -d \\" -f2}.chomp
result = output
end
result
end
end
Facter.add("apache_ver") do
confine :apache => :true
setcode do
begin
Facter.apache_dir
rescue
Facter.loadfacts()
end
main_dir = Facter.value('apache_dir')
output = %x{#{main_dir}/bin/httpd -v | grep -vE 'built|Easy' | awk \{'print $3'\} | cut -d / -f2}.chomp
result = output
end
end