community.general.gunicorn (8.5.0) — module

Run gunicorn with various settings

Authors: Alejandro Gomez (@agmezr)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Starts gunicorn with the parameters specified. Common settings for gunicorn configuration are supported. For additional configuration use a config file See U(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

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Simple gunicorn run example
  community.general.gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run gunicorn on a virtualenv
  community.general.gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'
    venv: '/workspace/example/venv'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run gunicorn with a config file
  community.general.gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'
    conf: '/workspace/example/gunicorn.cfg'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run gunicorn as ansible user with specified pid and config file
  community.general.gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'
    conf: '/workspace/example/gunicorn.cfg'
    venv: '/workspace/example/venv'
    pid: '/workspace/example/gunicorn.pid'
    user: 'ansible'

Inputs

    
app:
    aliases:
    - name
    description:
    - The app module. A name refers to a WSGI callable that should be found in the specified
      module.
    required: true
    type: str

pid:
    description:
    - 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.
    type: path

user:
    description:
    - Switch worker processes to run as this user.
    type: str

venv:
    aliases:
    - virtualenv
    description:
    - Path to the virtualenv directory.
    type: path

chdir:
    description:
    - Chdir to specified directory before apps loading.
    type: path

config:
    aliases:
    - conf
    description:
    - Path to the gunicorn configuration file.
    type: path

worker:
    choices:
    - sync
    - eventlet
    - gevent
    - 'tornado '
    - gthread
    - gaiohttp
    description:
    - The type of workers to use. The default class (sync) should handle most "normal"
      types of workloads.
    type: str

Outputs

gunicorn:
  description: process id of gunicorn
  returned: changed
  sample: '1234'
  type: str