Forge Home

uwsgi

Install and configure uwsgi in Emperor mode

13,486 downloads

11,828 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 2.0.1 (latest)
  • 2.0.0 (deleted)
  • 1.3.2
released Sep 26th 2017
This version is compatible with:
  • Puppet Enterprise 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.7.0 < 6.0.0
  • , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'poikilotherm-uwsgi', '2.0.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add poikilotherm-uwsgi
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install poikilotherm-uwsgi --version 2.0.1

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

poikilotherm/uwsgi — version 2.0.1 Sep 26th 2017

puppet-uwsgi

A puppet module for installing and managing uWSGI (in emperor mode)

Build Status

WARNING: version 2.0 and newer of this module requires Puppet 4.7 and newer. See version 1.3.2 for compatibility with Puppet 3.

This module has its roots in the work of @rvdh and @jarshwah:

Description

This module installs and configures uWSGI in Emperor mode.

It can also create and manage uWSGI applications that run under the emperor, which are best defined in Hiera.

Just about every option is configurable, so it should work on most distributions by putting together a Hiera file.

Usage

There are two options to get uWSGI going on your machine: either include uwsgi and provide vassal configurations via uwsgi::app from Hiera or create resources via the defined type uwsgi::app by yourself (will include uwsgi for you).

If you are using this module on RedHat like distributions, be aware the the uWSGI or Python pip package is not contained in standard repos. By default, this module will include ::epel from stahnma/epel for management (see parameters below). Remember to include this in your Puppetfile if necessary!

Option 1: include uwsgi

  1. Add include uwsgi to your role or profile class.
  2. Add configuration to Hiera (minimal example given):
---
uwsgi::app:
  example:
    uid: example
    gid: example

Configure multiple applications (merged with 'deep' strategy):

# common.yaml
---
uwsgi::app:
  django_1:
    ensure: 'present'
    uid: 'django'
    gid: 'django'
    application_options:
      chdir: '/path/to/project'
      module: 'mysite.wsgi:application'
      socket: '/tmp/uwsgi_django.sock'


# role_app_server.yaml
---
uwsgi::app:
  django_2:
    ensure: 'present'
    uid: 'django'
    gid: 'django'
    application_options:
      chdir: '/path/to/project2'
      module: 'mysite.wsgi:application'
      socket: '/tmp/uwsgi_django2.sock'

Option 2: create uwsgi::app resources

  1. Add configuration to Hiera (minimal example given):
---
apps:
  example:
    uid: example
    gid: example
  1. Create resources (minimal example):
$apps = lookup('apps')
each($app) |$name, $options| {
  uwsgi::app { $name:
    * => $options,
  }
}

Limitations

  1. Users for your vassals are NOT managed by this module.
  2. This module uses unit testing and acceptance testing for the supported operating system versions. Try your luck on other platforms...
  3. This module does not support Puppet 3 or Puppet < 4.7 and heavily relies on Hiera 5 data-in-modules. Please upgrade.
  4. Installation of uWSGI
    • Except on Ubuntu 14.04 and Debian 7, uWSGI will be installed from package repos. This enables you to install more options for uWSGI like special loggers or language support. By default, this module will imitate the pip provider behaviour and install Python support.
    • When you use the pip provider, be aware that your uWSGI installation will only support Python. You can try to use the gem provider for Ruby / Rack support, but this is neither tested nor supported. There is no support for installing more modules via uwsgiconfig.py. (Happy to accept a PR lifting these limits...!)

Defined Types

uwsgi::app

Responsible for creating uWSGI applications (vassals) that run under the uWSGI emperor.

Parameters

  • uid The user to run the application as. Required. May be the user name or the id.

  • gid The group to run the application as. Required. May be the group name or the id.

  • ensure Ensure the config file exists. Default: 'present'

  • template The template used to construct the config file. Default: 'uwsgi/uwsgi_app.ini.erb'

  • application_options Hash of extra options to set in the application config file. Default: {} Example: { 'socket' => '/tmp/app.socket' }

  • environment_variables Hash of extra environment variabls to set in the application config file. Default: {} Example: { 'DJANGO_ENV_VAR' => 'example' }

Using Hiera

Configure a Django application:

---
uwsgi::app:
  django:
    ensure: 'present'
    uid: 'django'
    gid: 'django'
    application_options:
      chdir: '/path/to/project'
      module: 'mysite.wsgi:application'
      socket: '/tmp/uwsgi_django.sock'
      master: 'True'
      vaccum: 'True'
      max-requests: '5000'
      buffer-size: '32768'
      processes: 4
      threads: 8

Classes

uwsgi

The main entry point. Simply include uwsgi to accept all the default parameters. The service file template will, by default, auto-configure itself depending on the service provider (RedHat init.d / UpStart / SystemD).

Parameters

  • app A hash of uwsgi::app resources to create for you. See above. Default: {} Merge behaviour: deep
  • plugins An array of package names to install when not using pip to install. By default this will install Python support for uWSGI. Default: depends on OS Merge behaviour: unique

Private subclasses

Any subclasses of ::uwsgi are private and normally you should not need to fiddle around with them. Instead, use parameters configurable via Hiera (see next section).

Parameters (via Hiera)

None of the following parameters are required. Depending on your distribution and version, this provides sane defaults.

If you want to add a new distribution or version, have a look at the data directory of this module.

Most certainly you want to configure some emperor options. Example:

---
uwsgi::emperor_options:
  vacuum: 'True'
  reload-mercy: 8

Installation

  • uwsgi::install::package_name The package name to install.
  • uwsgi::install::package_ensure Package state. Cascades to config files.
  • uwsgi::install::package_provider The provider to use to install the package.
  • uwsgi::install::plugins Array of plugin package names, loads from uwsgi::plugins by default.

Build and Runtime dependencies

  • uwsgi::packages::manage_epel Choose to depend on epel module. Default on RedHat.
  • uwsgi::packages::install_pip Install pip if it's not already installed? Don't by default.
  • uwsgi::packages::install_python_dev Install python header files and other build time dependencies if not already installed? Don't by default. Merge strategy "unique".
  • uwsgi::packages::python_dev String or Array of build time dependency package names.
  • uwsgi::packages::python_pip String of pip package name.

Emperor Configuration

  • uwsgi::config::configfile Absolute path to config file.
  • uwsgi::config::log_rotate Install logrotate rule? Don't by default.
  • uwsgi::config::app_directory Absolute path to store vassal configurations.
  • uwsgi::config::pidfile Absolute path to pid file.
  • uwsgi::config::socket Absolute path to socket file.
  • uwsgi::config::emperor_options Hash of extra options for emperor ini file.
  • uwsgi::config::tyrant Start emperor in "tryant" mode?
  • uwsgi::config::logfile Absolute path to log file.

Service

  • uwsgi::service::manage_file Provide a init system dependent start script/file? (or use package provided)
  • uwsgi::service::provider Service provider of this system. Depends on your distribution.
  • uwsgi::service::file Absolute path to script file.
  • uwsgi::service::file_mode Mode of script file.
  • uwsgi::service::template Template to use (auto depends on service provider).
  • uwsgi::service::ensure Service status to ensure. Defaults to running.
  • uwsgi::service::enable Start service at boot? Default to true.
  • uwsgi::service::binary_directory Aboslute path to uwsgi binary.
  • uwsgi::service::kill_signal Systemd specific: signal to use for termination of uWSGI.

Contributers

Contributions will be gratefully accepted. Please go to the project page, fork the project, make your changes locally and then raise a pull request. Details on how to do this are available at https://guides.github.com/activities/contributing-to-open-source.

Additional Contributers

Release PR/Issue/commit Contributer
2.0.0 Refactor for Puppet 5, add RSpec and Beaker tests @poikilotherm
1.3.1 Add systemd support for Debian 8 @rvdh
1.3.0 Add systemd support @andy-s-clark
1.3.0 Make tyrant mode configurable @TravellingGuy
1.3.0 Additional Options @elmerfud
1.2.0 Support repeated application options by passing an array of values @rayl
1.1.0 Fix typo in Upstart script @Kodapa
1.1.0 Support multiple env options @kimor79
1.0.1 Fix logging when using init.d @kimor79
1.0.0 init.d support @kimor79
0.9.0 @jarshwah