Defined Type: python::gunicorn

Defined in:
manifests/gunicorn.pp

Summary

Manages Gunicorn virtual hosts.

Overview

Examples:

run gunicorn on vhost in virtualenv /var/www/project1

python::gunicorn { 'vhost':
  ensure      => present,
  virtualenv  => '/var/www/project1',
  mode        => 'wsgi',
  dir         => '/var/www/project1/current',
  bind        => 'unix:/tmp/gunicorn.socket',
  environment => 'prod',
  owner       => 'www-data',
  group       => 'www-data',
  appmodule   => 'app:app',
  osenv       => { 'DBHOST' => 'dbserver.example.com' },
  timeout     => 30,
  template    => 'python/gunicorn.erb',
}

Parameters:

  • ensure (Enum['present', 'absent']) (defaults to: present)
  • config_dir (Any) (defaults to: '/etc/gunicorn.d')

    Configure the gunicorn config directory path.

  • manage_config_dir (Any) (defaults to: false)

    Set if the gunicorn config directory should be created.

  • virtualenv (Any) (defaults to: false)

    Run in virtualenv, specify directory.

  • mode (Enum['wsgi', 'django']) (defaults to: 'wsgi')

    Gunicorn mode.

  • dir (Stdlib::Absolutepath)

    Application directory.

  • bind (Any) (defaults to: false)

    Bind on: ‘HOST’, ‘HOST:PORT’, ‘unix:PATH’. Default: system-wide: unix:/tmp/gunicorn-$name.socket

    virtualenv:  unix:${virtualenv}/${name}.socket
    
  • environment (Any) (defaults to: false)

    Set ENVIRONMENT variable.

  • appmodule (Any) (defaults to: 'app:app')

    Set the application module name for gunicorn to load when not using Django.

  • osenv (Any) (defaults to: false)

    Allows setting environment variables for the gunicorn service. Accepts a hash of ‘key’: ‘value’ pairs.

  • timeout (Any) (defaults to: 30)

    Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds.

  • template (Any) (defaults to: 'python/gunicorn.erb')

    Which ERB template to use.

  • args (Any) (defaults to: [])

    Custom arguments to add in gunicorn config file.

  • owner (Any) (defaults to: 'www-data')
  • group (Any) (defaults to: 'www-data')
  • workers (Any) (defaults to: false)
  • access_log_format (Any) (defaults to: false)
  • accesslog (Any) (defaults to: false)
  • errorlog (Any) (defaults to: false)
  • log_level (Enum['debug', 'info', 'warning', 'error', 'critical']) (defaults to: 'error')


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'manifests/gunicorn.pp', line 36

define python::gunicorn (
  Stdlib::Absolutepath $dir,
  Enum['present', 'absent'] $ensure                                = present,
  $config_dir                                                      = '/etc/gunicorn.d',
  $manage_config_dir                                               = false,
  $virtualenv                                                      = false,
  Enum['wsgi', 'django'] $mode                                     = 'wsgi',
  $bind                                                            = false,
  $environment                                                     = false,
  $owner                                                           = 'www-data',
  $group                                                           = 'www-data',
  $appmodule                                                       = 'app:app',
  $osenv                                                           = false,
  $timeout                                                         = 30,
  $workers                                                         = false,
  $access_log_format                                               = false,
  $accesslog                                                       = false,
  $errorlog                                                        = false,
  Enum['debug', 'info', 'warning', 'error', 'critical'] $log_level = 'error',
  $template                                                        = 'python/gunicorn.erb',
  $args                                                            = [],
) {
  if $manage_config_dir {
    file { $config_dir:
      ensure => directory,
      mode   => '0755',
      owner  => 'root',
      group  => 'root',
    }
    file { "${config_dir}/${name}":
      ensure  => $ensure,
      mode    => '0644',
      owner   => 'root',
      group   => 'root',
      content => template($template),
      require => File[$config_dir],
    }
  } else {
    file { "${config_dir}/${name}":
      ensure  => $ensure,
      mode    => '0644',
      owner   => 'root',
      group   => 'root',
      content => template($template),
    }
  }

}