diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index 92a07c25..b943e332 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -42,6 +42,9 @@ # [*template*] # Which ERB template to use. Default: python/gunicorn.erb # +# [*args*] +# Custom arguments to add in gunicorn config file. Default: [] +# # === Examples # # python::gunicorn { 'vhost': @@ -83,6 +86,7 @@ $errorlog = false, $log_level = 'error', $template = 'python/gunicorn.erb', + $args = [], ) { # Parameter validation diff --git a/spec/defines/gunicorn_spec.rb b/spec/defines/gunicorn_spec.rb index 5e51bb21..116ad414 100644 --- a/spec/defines/gunicorn_spec.rb +++ b/spec/defines/gunicorn_spec.rb @@ -26,6 +26,11 @@ 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 + + context 'test-app with custom gunicorn preload arguments' do + let(:params) { { :dir => '/srv/testapp', :args => ['--preload'] } } + it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(/--preload/) } + end end end end diff --git a/templates/gunicorn.erb b/templates/gunicorn.erb index 7db470e5..07605ade 100644 --- a/templates/gunicorn.erb +++ b/templates/gunicorn.erb @@ -24,6 +24,11 @@ CONFIG = { 'python': '/usr/bin/python', <% end -%> 'args': ( +<% if @args.any? -%> +<% for arg in @args do -%> + '<%= arg %>', +<% end -%> +<% end -%> <% if !@virtualenv and !@bind -%> '--bind=unix:/tmp/gunicorn-<%= @name %>.socket', <% elsif @virtualenv and !@bind -%>