---
# tasks file for sbux-nodejs
- name: Fetch nodejs archive
  get_url: 
    url={{ nodejs_bin_url }}
    dest=/opt/node-v{{ nodejs_version }}.tar.gz
    force=no

- name: Un-archive nodejs
  unarchive:
    copy=no
    src=/opt/node-v{{ nodejs_version }}.tar.gz
    dest=/opt/
    creates=/opt/node-v{{ nodejs_version }}-linux-x{{ansible_userspace_bits|replace('32', '86')}}

- name: Prepare link to latest nodejs version 
  file:
    state=link
    src=/opt/node-v{{ nodejs_version }}-linux-x{{ansible_userspace_bits|replace('32', '86')}}
    dest=/opt/node
    force=yes

- name: Prepare links to nodejs binaries
  file:
    state=link
    src=/opt/node/bin/{{ item }}
    dest=/usr/bin/{{ item }}
    force=yes
  with_items:
    - node
    - npm
---
# tasks file for sbux-nodejs
- name: Fetch nodejs archive
  get_url: 
    url={{ nodejs_bin_url }}
    dest=/opt/node-v{{ nodejs_version }}.tar.gz
    force=no

- name: Un-archive nodejs
  unarchive:
    copy=no
    src=/opt/node-v{{ nodejs_version }}.tar.gz
    dest=/opt/
    creates=/opt/node-v{{ nodejs_version }}-linux-x{{ansible_userspace_bits|replace('32', '86')}}

- name: Prepare link to latest nodejs version 
  file:
    state=link
    src=/opt/node-v{{ nodejs_version }}-linux-x{{ansible_userspace_bits|replace('32', '86')}}
    dest=/opt/node
    force=yes

- name: Prepare links to nodejs binaries
  file:
    state=link
    src=/opt/node/bin/{{ item }}
    dest=/usr/bin/{{ item }}
    force=yes
  with_items:
    - node
    - npm

- name: Ensure proper PATH for nodejs
  lineinfile:
    line={{ item }}
    dest=/etc/profile.d/99-node_path.sh
    create=yes
  with_items:
    - export PATH=/opt/node/bin/:$PATH

Add node to the PATH
Add node to the PATH
