/ansible-role-pm2

Provision a virtual machine with node applications managed by PM2 using Ansible.

MIT LicenseMIT

Ansible Role: PM2

Build Status Stability Releases Ansible Galaxy MIT licensed

  • Install PM2 to any desired location - A node application manager
  • Clone/Pull node applications from remote repositories
  • Install node packages required for each specified application
  • Copy configuration files
  • Create databases
  • Import database files
  • Run initialization script
  • Start application, and wait for response
  • Flush logs

Requirements

None.

Role Variables

To cleanly install PM2, use pm2_clean_install.

pm2_clean_install: true

Configure each node application as an array item in node_apps.

This unique configuration is required by you, otherwise this role will not install any services into the PM2 daemon.

node_apps:
  - name: myApp
    port: 3000
    location: /opt/myapp
    start: app.js
    init: reset.js
    repository: ssh://git@bitbucket.org/mybitbucket/myapp.git
    database:
      name: myapp
      file: database.sql
    config:
      origin: config/local-example.js
      destination: config/local.js

Dependencies

  • None.

Example Playbook

- { role: fubarhouse.pm2 }

Installation

  • Add the PM2 role to your playbook.
  • Modify above variables as desired.

License

MIT / BSD

Author Information

This role was created in 2016 by Karl Hepworth.