Showing with 25 additions and 8 deletions.
  1. +1 −1 Modulefile
  2. +3 −0 README.md
  3. +1 −1 lib/facter/pip_version.rb
  4. +1 −1 lib/facter/python_version.rb
  5. +1 −1 lib/facter/virtualenv_version.rb
  6. +7 −0 manifests/gunicorn.pp
  7. +6 −1 manifests/pip.pp
  8. +3 −2 manifests/requirements.pp
  9. +1 −1 templates/gunicorn.erb
  10. +1 −0 tests/gunicorn.pp
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'stankevich-python'
version '1.7.13'
version '1.7.14'
source 'git://github.com/stankevich/puppet-python.git'
author 'stankevich'
license 'Apache License, Version 2.0'
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ Manages Gunicorn virtual hosts.

**osenv** - Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. Default: false

**timeout** - Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds. Default: 30

**template** - Which ERB template to use. Default: python/gunicorn.erb

```puppet
Expand All @@ -188,6 +190,7 @@ Manages Gunicorn virtual hosts.
environment => 'prod',
appmodule => 'app:app',
osenv => { 'DBHOST' => 'dbserver.example.com' },
timeout => 30,
template => 'python/gunicorn.erb',
}
```
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/pip_version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Make pip version available as a fact
# Works with pip loaded and without, pip installed using pip and package installed
require 'puppet'
pkg = Puppet::Type.type(:package).new(:name => "python-pip")
pkg = Puppet::Type.type(:package).new(:name => "python-pip",:allow_virtual => 'false')
Facter.add("pip_version") do
has_weight 100
setcode do
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/python_version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Make python versions available as facts
# In lists default python and system python versions
require 'puppet'
pkg = Puppet::Type.type(:package).new(:name => "python")
pkg = Puppet::Type.type(:package).new(:name => "python",:allow_virtual => 'false')

Facter.add("system_python_version") do
setcode do
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/virtualenv_version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Make virtualenv version available as a fact
# Works with virualenv loaded and without, pip installed and package installed
require 'puppet'
pkg = Puppet::Type.type(:package).new(:name => "virtualenv")
pkg = Puppet::Type.type(:package).new(:name => "virtualenv",:allow_virtual => 'false')
Facter.add("virtualenv_version") do
has_weight 100
setcode do
Expand Down
7 changes: 7 additions & 0 deletions manifests/gunicorn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
# hash of 'key': 'value' pairs.
# Default: false
#
# [*timeout*]
# Allows setting the gunicorn idle worker process time before being killed.
# The unit of time is seconds.
# Default: 30
#
# [*template*]
# Which ERB template to use. Default: python/gunicorn.erb
#
Expand All @@ -50,6 +55,7 @@
# group => 'www-data',
# appmodule => 'app:app',
# osenv => { 'DBHOST' => 'dbserver.example.com' },
# timeout => 30,
# template => 'python/gunicorn.erb',
# }
#
Expand All @@ -70,6 +76,7 @@
$group = 'www-data',
$appmodule = 'app:app',
$osenv = false,
$timeout = 30,
$template = 'python/gunicorn.erb',
) {

Expand Down
7 changes: 6 additions & 1 deletion manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
$install_args = '',
$uninstall_args = '',
$timeout = 1800,
$log_dir = '/',
) {

# Parameter validation
Expand All @@ -79,7 +80,7 @@
}

$cwd = $virtualenv ? {
'system' => '/',
'system' => $log_dir,
default => $virtualenv,
}

Expand Down Expand Up @@ -152,6 +153,7 @@
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${cwd}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure} || ${pip_env} --log ${cwd}/pip.log install ${install_args} ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure} ;}",
unless => "${pip_env} freeze | grep -i -e ${grep_regex}",
user => $owner,
cwd => $cwd,
environment => $environment,
path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
timeout => $timeout,
Expand All @@ -164,6 +166,7 @@
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${cwd}/pip.log install \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${cwd}/pip.log install ${proxy_flag} ${install_args} ${install_editable} ${source} ;}",
unless => "${pip_env} freeze | grep -i -e ${grep_regex}",
user => $owner,
cwd => $cwd,
environment => $environment,
path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
timeout => $timeout,
Expand All @@ -176,6 +179,7 @@
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${install_args} ${install_editable} ${source} ;}",
unless => "${pip_env} search ${source} | grep -i INSTALLED | grep -i latest",
user => $owner,
cwd => $cwd,
environment => $environment,
path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
timeout => $timeout,
Expand All @@ -188,6 +192,7 @@
command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag}",
onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}",
user => $owner,
cwd => $cwd,
environment => $environment,
path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
timeout => $timeout,
Expand Down
5 changes: 3 additions & 2 deletions manifests/requirements.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
$forceupdate = false,
$cwd = undef,
$extra_pip_args = '',
$fix_requirements_owner = true
$fix_requirements_owner = true,
$log_dir = '/',
) {

if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') {
Expand All @@ -81,7 +82,7 @@
}

$rootdir = $virtualenv ? {
'system' => '/',
'system' => $log_dir,
default => $virtualenv,
}

Expand Down
2 changes: 1 addition & 1 deletion templates/gunicorn.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CONFIG = {
'--bind=<%= @bind %>',
<% end -%>
'--workers=<%= @processorcount.to_i*2 %>',
'--timeout=30',
'--timeout=<%= @timeout %>',
<% if @mode != 'django' -%>
'<%= @appmodule %>',
<% end -%>
Expand Down
1 change: 1 addition & 0 deletions tests/gunicorn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
environment => 'prod',
appmodule => 'app:app',
osenv => { 'DBHOST' => 'dbserver.example.com' },
timeout => 30,
template => 'python/gunicorn.erb',
}