Changeset View
Changeset View
Standalone View
Standalone View
manifests/instance.pp
# == Defined Type: gunicorn::instance | # == Defined Type: gunicorn::instance | ||||
# | # | ||||
# gunicorn::instance defines an instance of gunicorn | # gunicorn::instance defines an instance of gunicorn | ||||
# | # | ||||
# === Parameters | # === Parameters | ||||
# | # | ||||
# [*ensure*] | # [*ensure*] | ||||
# Whether the instance should be enabled, present (but disabled) or absent. | # Whether the instance should be enabled, present (but disabled) or absent. | ||||
# | # | ||||
# [*environment*] | |||||
# A hash of environment variables to start the service with. | |||||
# | |||||
# [*executable*] | # [*executable*] | ||||
# The wsgi callable to pass to gunicorn | # The wsgi callable to pass to gunicorn | ||||
# | # | ||||
# [*settings*] | # [*settings*] | ||||
# a hash of settings for the given site. | # a hash of settings for the given site. | ||||
# | # | ||||
# === Examples | # === Examples | ||||
# | # | ||||
# gunicorn::instance {'foo': | # gunicorn::instance {'foo': | ||||
# ensure => enabled, | # ensure => enabled, | ||||
# environment => { | |||||
# FOOENV => 'foovar', | |||||
# } | |||||
# executable => 'foo.wsgi:app' | # executable => 'foo.wsgi:app' | ||||
# user => 'foouser', | # user => 'foouser', | ||||
# group => 'foogroup', | # group => 'foogroup', | ||||
# config_mode => 0644 | # config_mode => 0644 | ||||
# settings => { | # settings => { | ||||
# plugin => 'python3', | # plugin => 'python3', | ||||
# protocol => $uwsgi_protocol, | # protocol => $uwsgi_protocol, | ||||
# socket => $uwsgi_listen_address, | # socket => $uwsgi_listen_address, | ||||
Show All 20 Lines | |||||
define gunicorn::instance ( | define gunicorn::instance ( | ||||
$executable, | $executable, | ||||
$user = 'root', | $user = 'root', | ||||
$group = 'root', | $group = 'root', | ||||
$ensure = 'enabled', | $ensure = 'enabled', | ||||
$config_mode = '0644', | $config_mode = '0644', | ||||
$working_dir = undef, | $working_dir = undef, | ||||
$log_only_errors = true, | $log_only_errors = true, | ||||
$settings = {} | $settings = {}, | ||||
$environment = {} | |||||
) { | ) { | ||||
$config_file = "/etc/gunicorn/instances/${name}.cfg" | $config_file = "/etc/gunicorn/instances/${name}.cfg" | ||||
$service_name = "gunicorn-${name}" | $service_name = "gunicorn-${name}" | ||||
$service_file = "/etc/systemd/system/${service_name}.service" | $service_file = "/etc/systemd/system/${service_name}.service" | ||||
$tmpfiles_file = "/etc/tmpfiles.d/${service_name}.conf" | $tmpfiles_file = "/etc/tmpfiles.d/${service_name}.conf" | ||||
$runtime_dir = "/run/gunicorn/${name}" | $runtime_dir = "/run/gunicorn/${name}" | ||||
if $working_dir { | if $working_dir { | ||||
Show All 24 Lines | 'enabled', 'present': { | ||||
group => $group, | group => $group, | ||||
mode => $config_mode, | mode => $config_mode, | ||||
content => template('gunicorn/gunicorn-instance.cfg.erb'), | content => template('gunicorn/gunicorn-instance.cfg.erb'), | ||||
notify => Service[$service_name], | notify => Service[$service_name], | ||||
} | } | ||||
# Uses variables: | # Uses variables: | ||||
# - $config_file | # - $config_file | ||||
# - $environment | |||||
# - $executable | # - $executable | ||||
# - $group | # - $group | ||||
# - $name | # - $name | ||||
# - $runtime_dir | # - $runtime_dir | ||||
# - $user | # - $user | ||||
# - $working_dir_override | # - $working_dir_override | ||||
file {$service_file: | file {$service_file: | ||||
ensure => present, | ensure => present, | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |