steampunk.unit.python_app (0.7.1) — module

Manage NGINX Unit python application

Authors: Tadej Borovšak (@tadeboro)

Install collection

Install with ansible-galaxy collection install steampunk.unit:==0.7.1


Add to requirements.yml

  collections:
    - name: steampunk.unit
      version: 0.7.1

Description

Manage NGINX Unit python application configuration.

Upstream docs are at U(https://unit.nginx.org/configuration/#python).

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create python 2 application
  steampunk.unit.python_app:
    name: demo
    version: "2"
    no_processes: 10
    working_directory: /www/store/
    path: /www/store/cart/
    home: /www/store/.virtualenv/
    module": wsgi
    user": www
    group": www
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete application
  steampunk.unit.python_app:
    name: demo
    state: absent

Inputs

    
home:
    description:
    - Virtual environment to use. Absolute, or relative to I(working_directory).
    type: path

name:
    description:
    - Application name.
    required: true
    type: str

path:
    description:
    - Additional lookup path for Python modules; this string is inserted into C(sys.path).
    type: str

user:
    description:
    - Username that runs the app process. If not set, nobody is used.
    type: str

group:
    description:
    - Group name that runs the app process. If not set, the user's primary group is used.
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - State of the manager resource.
    type: str

limits:
    description:
    - Set the application's lifecycle parameters.
    - Upstream documentation is available at U(https://unit.nginx.org/configuration/#configuration-proc-mgmt-lmts).
    suboptions:
      requests:
        description:
        - Maximum number of requests Unit allows an app process to serve. If the limit
          is reached, the process is restarted; this helps to mitigate possible memory
          leaks or other cumulative issues.
        type: int
      timeout:
        description:
        - Request timeout in seconds. If an app process exceeds this limit while handling
          a request, Unit alerts it to cancel the request and returns an HTTP error to
          the client.
        type: int
    type: dict

module:
    description:
    - WSGI module to run.
    - Required if I(state) is C(present).
    type: str

version:
    description:
    - Version of python module to use.
    - Use this module if you have more than one version of python module installed (eg.
      python 2 and python 3).
    - If this option is not set, unit will use the latest available module.
    type: str

provider:
    description:
    - Connection parameters.
    suboptions:
      ca_path:
        description:
        - Path to the CA bundle that should be used to validate the backend certificate.
        - If this parameter is not set, module will use the CA bundle that python is using.
        - Can also be set using the  I(UNIT_CA_PATH) environment variable.
        type: path
      endpoint:
        description:
        - HTTP or UNIX uri that should be used to communicate with the Unit.
        - The uri B(MUST) be prefixed by either C(http://), C(https://), or C(unix://).
        - By default, modules will try to connect to I(unix:///var/run/unit/control.sock),
          and if this socket does not exist, fallback to I(unix:///var/run/control.unit.sock).
        - Can also be set using the I(UNIT_ENDPOINT) environment variable.
        type: str
      password:
        description:
        - Password that is used when the I(endpoint) is protected using the basic authentication.
        - This parameter is ignored when the I(enpoint) parameter points to an unix socket.
        - Value is masked in the logs.
        - Can also be set using the I(UNIT_ENDPOINT) environment variable.
        type: str
      username:
        description:
        - Username that is used when the I(enpoint) is protected using the basic authentication.
        - This parameter is ignored when the I(enpoint) parameter points to an unix socket.
        - Can also be set using the I(UNIT_ENDPOINT) environment variable.
        type: str
      verify:
        default: true
        description:
        - Flag that controls the certificate validation.
        - If you are using self-signed certificates, you can set this parameter to C(false).
        - ONLY USE THIS PARAMETER IN DEVELOPMENT SCENARIOS! In you use self-signed certificates
          in production, see the I(auth.ca_path) parameter.
        - Can also be set using the  I(UNIT_VERIFY) environment variable.
        type: bool
    type: dict

processes:
    description:
    - Dynamic process limits.
    - Mutually exclusive with I(no_processes).
    - Upstream documentation is available at U(https://unit.nginx.org/configuration/#configuration-proc-mgmt-prcs).
    suboptions:
      idle_timeout:
        description:
        - Time in seconds that Unit waits before terminating an idle process which exceeds
          spare.
        type: int
      max:
        description:
        - Maximum number of application processes that Unit will maintain (busy and idle).
        type: int
      spare:
        description:
        - Minimum number of idle processes that Unit tries to reserve for an app. When
          the app is started, spare idle processes are launched; Unit assigns incoming
          requests to existing idle processes, forking new idles to maintain the spare
          level if max allows. As processes complete requests and turn idle, Unit terminates
          extra ones after idle_timeout.
        type: int
    type: dict

environment:
    description:
    - Environment variables to be passed to the application.
    type: dict

no_processes:
    description:
    - Number of processes that should be running at one time.
    - Mutually exclusive with I(processes).
    - Upstream documentation is available at U(https://unit.nginx.org/configuration/#configuration-proc-mgmt-prcs).
    type: int

working_directory:
    description:
    - The app's working directory. If not set, the Unit daemon's working directory is
      used.
    type: path

Outputs

object:
  contains:
    environment:
      description: Environment variables to be passed to the application.
      returned: if set
      type: dict
    group:
      description: Group name that runs the app process.
      returned: if set
      type: str
    home:
      description: Virtual environment in use.
      returned: if set
      type: str
    limits:
      contains:
        requests:
          description: Maximum number of requests Unit allows an app to serve.
          type: int
        timeout:
          description: Request timeout in seconds.
          type: int
      description: Set the application's lifecycle parameters.
      returned: if set
      type: dict
    module:
      description: WSGI module to run.
      returned: always
      type: str
    name:
      description: Application name.
      returned: always
      type: str
    no_processes:
      description: Number of processes that should be running at one time.
      returned: if set
      type: int
    path:
      description: Additional lookup path for Python modules.
      returned: if set
      type: str
    processes:
      contains:
        idle_timeout:
          description: Time in seconds before terminating an idle process.
          type: int
        max:
          description: Maximum number of application processes.
          type: int
        spare:
          description: Minimum number of idle processes.
          type: int
      description: Dynamic process limits.
      returned: if set
      type: dict
    user:
      description: Username that runs the app process.
      returned: if set
      type: str
    working_directory:
      description: The app's working directory.
      returned: if set
      type: str
  description: Object representing NGINX Unit Python application.
  returned: On success and if I(state) == C(present)
  type: dict