DEBOPS.NODEJS(5)

NAME
debops.nodejs - Manage NodeJS environment using Ansible

SYNOPSIS

debops service/nodejs [--limit group,host,...] [--diff] [--check] [--tags tag1,tag2,...] [--skip-tags tag1,tag2,...] [<ansible-playbook options>] ...

DESCRIPTION

Node.js <https://nodejs.org/> is a JavaScript runtime environment which can be used to execute JS code outside of the browser. It is commonly used for server-side applications written in JavaScript.

There are two popular package managers in the Node.js ecosystem: NPM <https://npmjs.org/> which is bundled with Node.js, and Yarn <https://yarnpkg.org/>, a third-party package manager that is compatible with NPM.

The debops.nodejs Ansible role can be used to manage a Node.js environment on a host. By default, it will install Node.js, NPM and Yarn packages included in a given OS release (if possible), but it can also automatically install or upgrade an existing installation to their upstream versions.

GETTING STARTED

  NodeJS and NPM from Debian Backports

On a given Debian Oldstable release, the role will install the nodejs and npm packages from the backports repository of the same OS release to ensure feature parity between the Oldstable and Stable Debian releases. This means that, for example, on Debian Stretch the role will use the Node.js and NPM packages from the stretch-backports repository instead of the OS release repository.

Newer Node.js and NPM packages can be installed using the NodeSource repository, which can be enabled using the nodejs__node_upstream variable.

  Example inventory

To configure a Node.js environment on a given host or set of hosts, they need to be added to [debops_service_nodejs] Ansible group in the inventory:

[debops_service_nodejs]
hostname

  Example playbook

If you are using this role without DebOps, here's an example Ansible playbook that uses the debops.nodejs role:

---
- name: Manage NodeJS environment
  collections: [ 'debops.debops', 'debops.roles01',
                 'debops.roles02', 'debops.roles03' ]
  hosts: [ 'debops_service_nodejs' ]
  become: True
  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'
  roles:
    - role: keyring
      tags: [ 'role::keyring', 'skip::keyring', 'role::nodejs' ]
      keyring__dependent_apt_keys:
        - '{{ nodejs__keyring__dependent_apt_keys }}'
    - role: apt_preferences
      tags: [ 'role::apt_preferences', 'skip::apt_preferences' ]
      apt_preferences__dependent_list:
        - '{{ nodejs__apt_preferences__dependent_list }}'
    - role: nodejs
      tags: [ 'role::nodejs', 'skip::nodejs' ]

AUTHOR
Maciej Delmanowski, Patrick Heeney

COPYRIGHT
2014-2022, Maciej Delmanowski, Nick Janetakis, Robin Schneider and others