Skip to content

Commit

Permalink
Merge pull request #95 from actionjack/syslog-support
Browse files Browse the repository at this point in the history
Added syslog support.
  • Loading branch information
hogepodge committed Feb 24, 2014
2 parents 233df75 + cc55e5f commit 7371ec8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -351,6 +351,11 @@ replication configuration. Default: False *Note*: deprecated – use replica se
Specify extra configuration file parameters (i.e.
textSearchEnabled=true). Default: None

#####`syslog`
Sends all logging output to the host’s syslog system rather than to standard
output or a log file. Default: None
*Important*: You cannot use syslog with logpath.

#####`slave`
Set to true to configure the current instance to act as slave instance in a
replication configuration. Default: false
Expand Down
1 change: 1 addition & 0 deletions manifests/server.pp
Expand Up @@ -51,6 +51,7 @@
$slowms = undef,
$keyfile = undef,
$set_parameter = undef,
$syslog = undef,

# Deprecated parameters
$master = undef,
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/config.pp
Expand Up @@ -45,12 +45,15 @@
$directoryperdb = $mongodb::server::directoryperdb
$profile = $mongodb::server::profile
$set_parameter = $mongodb::server::set_parameter
$syslog = $mongodb::server::syslog

File {
owner => $user,
group => $group,
}

if ($logpath and $syslog) { fail('You cannot use syslog with logpath')}

if ($ensure == 'present' or $ensure == true) {

# Exists for future compatibility and clarity.
Expand Down
19 changes: 19 additions & 0 deletions spec/classes/server_config_spec.rb
Expand Up @@ -94,4 +94,23 @@
end
end

describe 'when specifying syslog value' do
context 'it should be set to true' do
let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = present $syslog = true }", "include mongodb::server"]}

it {
should contain_file('/etc/mongod.conf').with_content(/^syslog = true/)
}
end

context 'if logpath is also set an error should be raised' do
let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = present $syslog = true $logpath ='/var/log/mongo/mongod.log' }", "include mongodb::server"]}

it {
expect { should contain_file('/etc/mongod.conf') }.to raise_error(Puppet::Error, /You cannot use syslog with logpath/)
}
end

end

end
8 changes: 8 additions & 0 deletions templates/mongodb.conf.erb
@@ -1,8 +1,13 @@
# mongo.conf - generated from Puppet


<% if @logpath -%>
#where to log
logpath=<%= @logpath %>
<% if @logappend -%>
logappend=<%= @logappend %>
<% end -%>
<% end -%>
<% if @bind_ip -%>
# Set this option to configure the mongod or mongos process to bind to and
# listen for connections from applications on this address.
Expand Down Expand Up @@ -162,3 +167,6 @@ directoryperdb = <%= @directoryperdb %>
<% if @set_parameter -%>
setParameter = <%= @set_parameter %>
<% end -%>
<% if @syslog -%>
syslog = <%= @syslog %>
<% end -%>

0 comments on commit 7371ec8

Please sign in to comment.