gunicorn - Run gunicorn with various settings.

New in version 2.4.

Synopsis

  • Starts gunicorn with the parameters specified. Common settings for gunicorn configuration are supported. For additional configuration use a config file See https://gunicorn-docs.readthedocs.io/en/latest/settings.html for more options. It’s recommended to always use the chdir option to avoid problems with the location of the app.

Requirements

The below requirements are needed on the host that executes this module.

  • gunicorn

Parameters

Parameter Choices/Defaults Comments
app
required
The app module. A name refers to a WSGI callable that should be found in the specified module.

aliases: name
chdir
Chdir to specified directory before apps loading.
config
Path to the gunicorn configuration file.
pid
A filename to use for the PID file. If not set and not found on the configuration file a tmp pid file will be created to check a successful run of gunicorn.
user
Switch worker processes to run as this user.
venv
Path to the virtualenv directory.

aliases: virtualenv
worker
    Choices:
  • sync
  • eventlet
  • gevent
  • tornado
  • gthread
  • gaiohttp
The type of workers to use. The default class (sync) should handle most "normal" types of workloads.

Notes

Note

  • If not specified on config file, a temporary error log will be created on /tmp dir. Please make sure you have write access in /tmp dir. Not needed but will help you to identify any problem with configuration.

Examples

- name: simple gunicorn run example
  gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'

- name: run gunicorn on a virtualenv
  gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'
    venv: '/workspace/example/venv'

- name: run gunicorn with a config file
  gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'
    conf: '/workspace/example/gunicorn.cfg'

- name: run gunicorn as ansible user with specified pid and config file
  gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'
    conf: '/workspace/example/gunicorn.cfg'
    venv: '/workspace/example/venv'
    pid: '/workspace/example/gunicorn.pid'
    user: 'ansible'

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
gunicorn
string
changed
process id of gunicorn

Sample:
1234


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Author

  • Alejandro Gomez (@agmezr)

Hint

If you notice any issues in this documentation you can edit this document to improve it.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.5/modules/gunicorn_module.html