Skip to content

Commit

Permalink
Merge pull request voxpupuli#275 from xaniasd/master
Browse files Browse the repository at this point in the history
add configurable log level for gunicorn and unit tests
  • Loading branch information
Shiva Poudel committed Dec 16, 2015
2 parents 0d08d4e + 6c301da commit 19c6024
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions manifests/gunicorn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
$access_log_format = false,
$accesslog = false,
$errorlog = false,
$log_level = 'error',
$template = 'python/gunicorn.erb',
) {

Expand All @@ -88,6 +89,8 @@
fail('python::gunicorn: dir parameter must not be empty')
}

validate_re($log_level, 'debug|info|warning|error|critical', "Invalid \$log_level value ${log_level}")

file { "/etc/gunicorn.d/${name}":
ensure => $ensure,
mode => '0644',
Expand Down
31 changes: 31 additions & 0 deletions spec/defines/gunicorn_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper'

describe 'python::gunicorn', :type => :define do
let(:title) { 'test-app' }
context 'on Debian OS' do
let :facts do
{
:id => 'root',
:kernel => 'Linux',
:lsbdistcodename => 'squeeze',
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:concat_basedir => '/dne',
}
end

describe 'test-app with default parameter values' do
context 'configures test app with default parameter values' do
let(:params) { { :dir => '/srv/testapp' } }
it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(/--log-level=error/) }
end

context 'test-app with custom log level' do
let(:params) { { :dir => '/srv/testapp', :log_level => 'info' } }
it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(/--log-level=info/) }
end
end
end
end
3 changes: 3 additions & 0 deletions templates/gunicorn.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ CONFIG = {
<% if @errorlog -%>
'--error-logfile=<%= @errorlog %>',
<% end -%>
<% if @log_level %>
'--log-level=<%= @log_level %>',
<% end -%>
<% if @mode != 'django' -%>
'<%= @appmodule %>',
<% end -%>
Expand Down

0 comments on commit 19c6024

Please sign in to comment.