From 9d15d4b41d178eeef33317ccd1d6a9bcca321686 Mon Sep 17 00:00:00 2001 From: Romain THERRAT Date: Thu, 11 Jun 2015 16:47:08 +0200 Subject: [PATCH] Add: apache_fact_version fact --- lib/facter/apache_fact_version.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/facter/apache_fact_version.rb diff --git a/lib/facter/apache_fact_version.rb b/lib/facter/apache_fact_version.rb new file mode 100644 index 0000000..70ab391 --- /dev/null +++ b/lib/facter/apache_fact_version.rb @@ -0,0 +1,15 @@ +Facter.add(:apache_fact_version) do + setcode do + + apache2_cmd_result = Facter::Util::Resolution.exec('[ "$( which apache2 2>/dev/null )" != "" ] && apache2 -v | head -n1 |cut -d"/" -f2|awk \'{ print $1 }\'') + httpd_cmd_result = Facter::Util::Resolution.exec('[ "$( which httpd 2>/dev/null )" != "" ] && httpd -v | head -n1 |cut -d"/" -f2|awk \'{ print $1 }\'') + + if not apache2_cmd_result.empty? + apache2_cmd_result + elsif not httpd_cmd_result.empty? + httpd_cmd_result + else + "" + end + end +end