Skip to content

Commit

Permalink
implement syslog_ng_version fact
Browse files Browse the repository at this point in the history
  • Loading branch information
faxm0dem committed Aug 21, 2015
1 parent 73fc93c commit 7b9954c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [What syslog_ng affects](#what-syslog_ng-affects)
* [Getting started with syslog_ng](#beginning-with-syslog_ng)
4. [Usage - Configuration options and additional functionality](#usage)
* [Facts](#facts)
* [Classes and defined types](#classes-and-defined-types)
5. [Implementation details](#implementation-details)
5. [Limitations - OS compatibility, etc.](#limitations)
Expand Down Expand Up @@ -151,6 +152,10 @@ Before the generated configuration would be applied, it is written to a temporar
it overwrites the real configuration file. So you do not have to worry about
configuration errors.

### Facts

The fact `syslog_ng_version` contains the installed version string *e.g.* `3.7.1`

### Classes and defined types

####Class: `syslog_ng`
Expand Down
6 changes: 6 additions & 0 deletions lib/facter/syslog_ng_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Facter.add(:syslog_ng_version) do
setcode do
Facter::Util::Resolution.exec("/usr/sbin/syslog-ng --version").lines.find { |l| l =~ /^syslog-ng/}.split(' ')[1]
end
end

30 changes: 30 additions & 0 deletions spec/unit/facter/syslog_ng_version_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require "spec_helper"

describe Facter::Util::Fact do
before {
Facter.clear
}

describe "syslog_ng" do
context 'returns version' do
it do
output = <<-EOS
syslog-ng 3.7.1
Installer-Version: 3.7.1
Revision:
Compile-Date: Aug 17 2015 14:25:00
Available-Modules: afamqp,basicfuncs,linux-kmsg-format,csvparser,system-source,sdjournal,afsmtp,afmongodb,mod-java,riemann,afsocket,cryptofuncs,trigger-source,afstomp,lua,confgen,rust,rss,afuser,affile,afsql,dbparser,tfgetent,geoip-plugin,graphite,pseudofile,mod-perl,kvformat,grok-parser,json-plugin,afprog,basicfuncs-plus,monitor-source,syslogformat,mod-python,date-parser
Enable-Debug: off
Enable-GProf: off
Enable-Memtrace: off
Enable-IPv6: on
Enable-Spoof-Source: off
Enable-TCP-Wrapper: off
Enable-Linux-Caps: off
EOS
Facter::Util::Resolution.expects(:exec).with("/usr/sbin/syslog-ng --version").returns(output)
Facter.value(:syslog_ng_version).should == "3.7.1"
end
end
end
end

0 comments on commit 7b9954c

Please sign in to comment.