grzegorznowak.nvm_node

Build Status

Ansible NVM Node

This tool installs Node.js using NVM (Node Version Manager) on Debian and Red Hat systems.

Installation

You have two options:

  • Use Ansible Galaxy: ansible-galaxy install grzegorznowak.nvm_node
  • Clone the repository directly.

Disclaimer

This installation method is quite specific and does not use common package managers like apt or yum. It also doesn't follow the official recommended practices for using NVM (see here). Version control is only managed through Ansible. Make sure this setup fits your needs. It's suited for development environments (about 70%) and less so for production (around 30%). It’s not ideal for multiple users on a single server (0% recommended), although it might work with some adjustments.

This installation process puts NVM in a global path and creates a symlink to /usr/local/bin for easy access. It modifies the global .bashrc file to add NVM paths for all users, which can interfere with the per-user functionality of NVM and may not work perfectly with some shell types, affecting the usage of globally installed npm packages.

However, NVM is still a preferred tool, and it may serve your needs well!

Requirements

No special dependencies, but it will install wget to download the NVM installation script.

Supported Systems

This role works with the following versions:

Ubuntu: 20.04, 18.04, 16.04, 14.04
Debian: buster, stretch
CentOS: 7

Variables

Defaults

    nvm_install_script_version: "0.33.11"   # The NVM installation script version (latest stable version as of now)
    nvm_user_name: "root"                   # You can specify a different user, which may provide a more standard NVM experience, but it hasn't been tested.
    nvm_dir: "/var/lib/nvm"                 # Default global installation directory. Must match the nvm_user_name variable.
    nvm_node_version: "8.11.3"              # Node.js version to install via NVM
    nvm_install_globally: []                # Specify libraries to install globally and symlink (details below)

Example Playbook

When cloned from GitHub
    ---
    - hosts: all
      vars:
        nvm_node_version: "4.1.1"
      roles:
        - role: ansible-nvm-node
When using Ansible Galaxy
    ---
    - hosts: all
      vars:
        nvm_node_version: "your.node.version"
      roles:
        - role: grzegorznowak.nvm_node        

Upgrading Node.js

To upgrade, simply change nvm_node_version to the desired version and rerun the playbook.

Installing Global Packages

For consistency, it's recommended to use this role for installing global packages. You can modify the nvm_install_globally variable like this:

nvm_install_globally: ['gulp']

You can also specify versions for global packages:

nvm_install_globally:
  - name: yarn
    version: 1.9.4

Or mix both methods:

nvm_install_globally:
  - gulp
  - lighthouse
  - name: yarn
    version: 1.9.4

This will install the specified libraries and create symlinks in the global $PATH for them to be accessible in specific environments (like cron jobs).

Testing

Requirements

You can use a helper script to set up a virtual environment with all necessary tools: ./bootstrap_test.sh

Then activate it with source test_env/bin/activate, or set it up manually for more control:

sudo apt install virtualenv python3-pip
virtualenv test_env --python=python3
source test_env/bin/activate
pip install -r test-requirements.txt

Testing with LXC Containers

Run tests using: molecule test

Additional Features from Molecule

You can use molecule converge to create instances on demand and molecule destroy to remove them afterwards. The possibilities are endless!

Kwiziq.com - An AI language learning platform

Spottmedia.com - Technology design, delivery, and consulting

Author Information

Created with care by Grzegorz Nowak.

Informazioni sul progetto

Installs node via nvm globally; includes molecule testing framework.

Installa
ansible-galaxy install grzegorznowak.nvm_node
Licenza
Unknown
Download
70.5k
Proprietario
Let's solve some more problems, shall we ?