Puppet Class: uwsgi

Defined in:
modules/uwsgi/manifests/init.pp

Overview

Class: uwsgi

uWSGI is a web application server, typically used in conjunction with Nginx to serve Python web applications, but capable of interoperating with a broad range of languages, protocols, and platforms.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'modules/uwsgi/manifests/init.pp', line 7

class uwsgi {
    # There are 30+ uWSGI plug-ins, installable via the dependency package
    # 'uwsgi-plugins-all'. But I'm going to go out on a limb here and predict
    # that we won't use any except these two.  -- OL
    if os_version('debian == jessie') {
        $plugins = [ 'uwsgi-plugin-python', 'uwsgi-plugin-python3', 'uwsgi-plugin-rack-ruby2.1' ]
    } elsif os_version('debian == stretch') {
        $plugins = [ 'uwsgi-plugin-python', 'uwsgi-plugin-python3', 'uwsgi-plugin-rack-ruby2.3' ]
    } elsif os_version('debian == buster') {
        $plugins = [ 'uwsgi-plugin-python', 'uwsgi-plugin-python3', 'uwsgi-plugin-rack-ruby2.5' ]
    }

    package { 'uwsgi': }
    package { $plugins: }

    exec { 'remove_uwsgi_initd':
        command => '/usr/sbin/update-rc.d -f uwsgi remove',
        onlyif  => '/usr/bin/find /etc/rc?.d -name \'[KS][0-9][0-9]uwsgi\' | grep -q .',
        require => Package['uwsgi'],
    }

    # Stop the default uwsgi service since it is incompatible with
    # our multi instance setup. The update-rc.d isn't good enough on
    # systemd instances
    service { 'uwsgi':
        ensure  => stopped,
        enable  => false,
        require => Package['uwsgi'],
    }

    file { [ '/etc/uwsgi/apps-available', '/etc/uwsgi/apps-enabled' ]:
        ensure  => directory,
        recurse => true,
        purge   => true,
        force   => true,
        require => Package['uwsgi', $plugins],
    }

    file { '/run/uwsgi':
        ensure => directory,
        owner  => 'www-data',
        group  => 'www-data',
        mode   => '0755',
    }

    # additionally, ensure that /run/uwsgi is created at boot
    systemd::tmpfile { 'uwsgi-startup':
        content => 'd /run/uwsgi 0755 www-data www-data',
    }
}