An opinionated Ansible role for installing Node Version Manager (nvm)
This role requires two separate tools be installed.
First it requires the 'ansible.utils' collection be installed from Ansible-Galaxy via:
ansible-galaxy collection install ansible.utilsSecondly it requires the jsonschema Python package be installed via:
pip3 install jsonschemanvm : [mapping] (required) contains the following fields:
-
source_url: [string] (optional) The http url to the nvm source repository to use. Defaults tohttps://github.com/nvm-sh/nvm -
users: [array of objects]A list of mappings containing the following fields:
-
name[string] (required)The user name for which to install the requested version of nvm for
-
version[string] (required)The version number of nvm to install for the user.
-
path[string] (optional)The user home directory relative path where nvm will be installed at.
-
remove[boolean] (optional)Indicates if NVM should be removed for this user. If set, then
versioncan not be present as well.
-
Example:
nvm:
source_url: https://myprivatecms.com/nvm
users:
- name: Joe
remove: true # Remove a previous installation for user before installing a different one in a custom location
- name: Joe
version: v0.39.0
path: ".local/development/nvm"
- name: Sally
version: v0.34.2
None, other then previously stated requirements.
Before the role can be used it needs to be added to the machine running the playbook, and as of writing this, this role is not hosted on Ansible-Galaxy only on Github.
-
Create a
requirements.ymlfile in the root directory of the playbook being worked on. -
Add the following definition inside the
requirements.ymlfile:
- name: hth-nvm
src: https://github.com/hrafnthor/ansible-nvm.git
scm: git- Install the requirements by executing
ansible-galaxy install -r .requirements.ymlThis will allow any playbook run from this machine to use the role hth-nvm
- hosts: all
vars:
- nvm:
- users:
- name: Joe
version: v0.39.0
path: ".local/nvm"
- name: Sally
version: v0.34.2
roles:
- hth-nvmMIT license. See attached license file.
Hrafn Thorvaldsson Find me at https://www.hth.is