sansible.nodejs
nodejs
This role installs and configures nodejs from NodeSource on Debian based systems.
Installation and Dependencies
To install this role run ansible-galaxy install sansible.nodejs
or add this to your roles.yml
- name: sansible.nodejs
version: v3.1
and run ansible-galaxy install -p ./roles -r roles.yml
Tags
This role uses two tags: build and configure
build- Installs nodejs.configure- does nothing (for now).
Examples
Simply install latest LTS version.
- name: Install Node.js
hosts: sandbox
pre_tasks:
- name: Update apt
become: yes
apt:
cache_valid_time: 1800
update_cache: yes
tags:
- build
roles:
- role: sansible.nodejs
sansible_nodejs_version: 4
Install latest LTS version, latest lorem-ipsum and v0.15.3 of forever NPMs.
NPM installation accepts the same arguments as the Ansible npm module,
with the exception that global is set to yes by default.
- name: Install Node.js
hosts: sandbox
pre_tasks:
- name: Update apt
become: yes
apt:
cache_valid_time: 1800
update_cache: yes
tags:
- build
roles:
- role: sansible.nodejs
sansible_nodejs_version: 4
sansible_nodejs_npms:
- name: lorem-ipsum
- name: forever
version: '0.15.3'
When using this role you may encounter permission issues when running commands such as NPM as a non-root user (see fixing npm permissions for more information). To fix permissions for a particular user you can pass in their name like so:
- name: Install Node.js
hosts: sandbox
pre_tasks:
- name: Update apt
become: yes
apt:
cache_valid_time: 1800
update_cache: yes
tags:
- build
roles:
- role: sansible.nodejs
sansible_nodejs_version: 9
sansible_nodejs_workspace_user: some_user
Development & Testing
If you want to work on this role, please start with running
make watch. This will re-provision docker images on any file changes.
ansible-galaxy install sansible.nodejs