roles/nodejs/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Mon, 29 Jan 2018 22:45:54 -0600
changeset 7 55b8db128364
parent 0 30d8bcb1ebb4
permissions -rw-r--r--
Removed unneeded npm command module.

---

# 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"