community.general.gunicorn 模块 – 使用各种设置运行 gunicorn

注意

此模块是 community.general 集合 (版本 10.1.0) 的一部分。

如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install community.general。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。

要在剧本中使用它,请指定: community.general.gunicorn

概要

要求

执行此模块的主机需要以下要求。

  • gunicorn

参数

参数

注释

app

别名:name

字符串 / 必需

应用程序模块。名称指的是应该在指定的模块中找到的 WSGI 可调用对象。

chdir

路径

在加载应用程序之前更改到指定的目录。

config

别名:conf

路径

gunicorn 配置文件的路径。

pid

路径

用于 PID 文件的文件名。如果未设置且未在配置文件中找到,则会创建一个临时 pid 文件以检查 gunicorn 是否成功运行。

user

字符串

将工作进程切换为以该用户身份运行。

venv

别名:virtualenv

路径

virtualenv 目录的路径。

worker

字符串

要使用的 worker 类型。默认类 (sync) 应该能够处理大多数“正常”类型的负载。

选项

  • "sync"

  • "eventlet"

  • "gevent"

  • "tornado "

  • "gthread"

  • "gaiohttp"

属性

属性

支持

描述

check_mode

支持:不支持

可以在 check_mode 下运行,并在不修改目标的情况下返回更改状态预测。

diff_mode

支持:不支持

在差异模式下,将返回有关已更改内容(或可能需要在 check_mode 中更改的内容)的详细信息。

备注

注意

  • 如果在配置文件中未指定,则会在 /tmp 目录中创建一个临时错误日志。请确保您对 /tmp 目录具有写入权限。不是必需的,但将有助于您识别任何配置问题。

示例

- name: Simple gunicorn run example
  community.general.gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'

- name: Run gunicorn on a virtualenv
  community.general.gunicorn:
    app: 'wsgi'
    chdir: '/workspace/example'
    venv: '/workspace/example/venv'

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

- 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'

返回值

常见返回值已记录在 此处,以下是此模块独有的字段

描述

gunicorn

字符串

gunicorn 的进程 ID

返回:已更改

示例: "1234"

作者

  • Alejandro Gomez (@agmezr)