src.nth.io/

summaryrefslogtreecommitdiff
path: root/roles/nodejs/tasks/main.yaml
blob: fca90086bf91379fba641505f55c81fd91652034 (plain)
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
---

# https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi

- name: download and unarchive nodejs
  become: yes
  unarchive:
    src: "https://nodejs.org/dist/v{{nodejs_version}}/{{nodejs_dir}}.tar.xz"
    dest: "/opt/"
    remote_src: yes
    creates: "/opt/{{nodejs_dir}}"

# sudo update-alternatives --install "/usr/bin/node" "node" "/opt/node/bin/node" 1
- name: update node alterantives
  become: yes
  alternatives:
    link: "/usr/bin/{{item}}"
    name: "{{item}}"
    path: "/opt/{{nodejs_dir}}/bin/{{item}}"
    priority: "1"
  with_items:
    - "node"
    - "npm"

- name: npm install global deps
  become: yes
  npm: name="{{item}}" global="yes"
  with_items:
    - "npm"
    - "node-gyp"

- name: update node-gyp alterantives
  become: yes
  alternatives:
    link: "/usr/bin/node-gyp"
    name: "node-gyp"
    path: "/opt/{{nodejs_dir}}/bin/node-gyp"
    priority: "1"