Skip to main content

Github Actions PyPI version Code style: black

ansible-modules-pm2

Ansible Module to Manage Processes via PM2

  • Manage the state of processes via pm2 process manager
  • Start/Stop/Restart/Reload/Delete applications

Tested on:

  • Host Python: 3.8
  • Target host Python: 2.7, 3.5, 3.6, 3.7, 3.8
  • Ansible: 2.8.10, 2.9.6 (Should work with older versions)

Installation

Install via pip:

pip install ansible-modules-pm2

PM2 package have to be installed to target hosts. For example, add following to your playbook to install pm2 globally:

- npm:
    name: pm2
    global: yes

Usage

Basic usage is similar to service or supervisorctl module: specify the name and its state. To start an app, give either script or config.

Examples

---
- name: Start myapp with process config file, if not running
  pm2:
    name: myapp
    config: /path/to/myapp/myapp.json
    state: started

- name: Start myapp.js, if not running
  pm2:
    name: myapp
    script: /path/to/myapp/myapp.js
    state: started

- name: Stop process named myapp, if running
  pm2:
    name: myapp
    state: stopped

- name: Restart myapp, in all cases
  pm2:
    name: myapp
    state: restarted

- name: Reload myapp, in all cases
  pm2:
    name: myapp
    state: reloaded

- name: Delete myapp, if exists
  pm2:
    name: myapp
    state: absent

- name: Specify pm2 executable path
  pm2:
    name: myapp
    state: started
    config: /path/to/myapp/myapp.json
    executable: /path/to/myapp/node_modules/.bin/pm2

- name: Also specify working directory where running pm2 command
  pm2:
    name: myapp
    state: started
    config: /path/to/myapp/myapp.json
    executable: /path/to/myapp/node_modules/.bin/pm2
    chdir: /path/to/working/directory

Arguments

Parameters Choices Comments
name (required) Name of the application.
Required for all cases to check current status of app
state started (default)
stopped
restarted
reloaded
absent
deleted
started/stopped/absent/deleted are idempotent actions that will not run commands unless necessary.
restarted will always restart the process.
reloaded will always reload.
Note that restarted will fail when the process does not exist (action does not start it automatically).
config Process configuration file, in JSON or YAML format.
Either config or script is required when state=started.
script Executalbe file to start.
Either config or script is required when state=started.
executable Path to pm2 executable.
chdir Change into this directory before running pm2 start command.
When state=started and this option is omitted, use the directory where config or script exists.

License

This software is licensed under GPLv3. See LICENSE for details.

Metadata

Release files for ansible-modules-pm2 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ansible-modules-pm2 0.1.0
File Size Uploaded Provenance Actions
ansible-modules-pm2-0.1.0.tar.gz 23.1 kB Without provenance Details for ansible-modules-pm2-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ansible-modules-pm2 0.1.0
File Interpreter ABI Platform Actions
ansible_modules_pm2-0.1.0-py3-none-any.whl Python 3 none any Details for ansible_modules_pm2-0.1.0-py3-none-any.whl

Total release size: 41.4 kB

Release files / ansible-modules-pm2-0.1.0.tar.gz

Download URL ansible-modules-pm2-0.1.0.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
497a37c4eee46133b34528a11a3bf9637f7bcc2c6300a75543e644e0b9c3fffa
BLAKE2b-256 checksum
How to use checksums
010bd052fe448789e51ca4886a9653e7aa0e093a619c1d05758b257a664b0182
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

Release files / ansible_modules_pm2-0.1.0-py3-none-any.whl

Download URL ansible_modules_pm2-0.1.0-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e18eff1379bc32149ca1a92ab8aef78e7c5531eeb7339d25eff68e9df2301e1
BLAKE2b-256 checksum
How to use checksums
d31278872d9eb96716c8075c4627e1f97961ea38fb8a38669230e9182bdb2bba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

Security for ansible-modules-pm2 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page