-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvm.yml
27 lines (25 loc) · 1.08 KB
/
nvm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#first seen here: http://www.snip2code.com/Snippet/63701/Ansible-task-to-install-nvm-and-node
# Here is how to install nvm and node in an Ansible task.
# I tried a bunch of different things, and as usual it's simple, but you have to get it right.
# The important part is that you have to shell with /bin/bash -c and source nvm.sh
---
- name: run the nvm tasks on the localhost
hosts: local
become: yes
become_user: siva
tasks:
- name: Install nvm
shell: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
args:
creates: '{{ ansible_env.HOME }}/.nvm/nvm.sh'
- name: Install node and set version
shell: '.{{ ansible_env.HOME }}/.nvm/nvm.sh && nvm install node && nvm alias default 9.11.1'
args:
creates: '{{ ansible_env.HOME }}/.nvm/alias'
chdir: "{{ ansible_env.HOME }}"
executable: /bin/bash
- name: Install Node.js and set version
shell: '. {{ ansible_env.HOME }}/.nvm/nvm.sh && nvm alias default 10.0.0'
args:
chdir: "{{ ansible_env.HOME }}"
executable: /bin/bash