-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathtasks_nvm.yml
More file actions
80 lines (73 loc) · 2.16 KB
/
Copy pathtasks_nvm.yml
File metadata and controls
80 lines (73 loc) · 2.16 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
- name: NVM | Check if nvm is present
command: test -s ~/.nvm/nvm.sh
ignore_errors: yes
changed_when: False
register: nvm_present
tags:
- nodejs
- name: NVM | Install dependencies
package:
name:
- curl
- git
become: true
when: nvm_present is failed
tags:
- nvm
- name: NVM | Install OS specific dependencies
package:
name:
- build-essential
- libssl-dev
update_cache: yes
become: true
when: nvm_present is failed and ansible_os_family == "Debian"
tags:
- nvm
- name: NVM | Install nvm {{ nvm_version }}
become: true
become_user: "{{ deploy_user }}"
shell: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
when: nvm_present is failed
tags:
- nvm
- name: NVM | Source nvm into ~/.profile
become: true
become_user: "{{ deploy_user }}"
lineinfile: dest=~/.profile line="source ~/.nvm/nvm.sh" create=yes
when: nvm_present is failed
tags:
- nvm
- name: NVM | Install {{ nodejs_version }} with nvm
shell: source ~/.profile && nvm install {{ nodejs_version }}
args:
executable: /bin/bash
become: true
become_user: "{{ deploy_user }}"
register: node_install_result
when: option_nodejs_install_with_nvm
changed_when: "'is already installed.' not in node_install_result.stdout"
tags:
- nvm
- name: NVM | Upgrade default node version to {{ nodejs_version }}, if needed (1/2)
shell: source ~/.profile && nvm ls | grep -e 'default -> {{ nodejs_version }}'
args:
executable: /bin/bash
become: true
become_user: "{{ deploy_user }}"
register: default_nodejs_version_ok
changed_when: False
ignore_errors: True
when: option_nodejs_install_with_nvm
tags:
- nvm
- name: NVM | Upgrade default node version to {{ nodejs_version }}, if needed (2/2)
shell: source ~/.profile && nvm alias default {{ nodejs_version }}
args:
executable: /bin/bash
become: true
become_user: "{{ deploy_user }}"
when: option_nodejs_install_with_nvm and default_nodejs_version_ok is failed
tags:
- nvm