---

- include_vars: "{{ansible_distribution}}.yml"

- name: Install Ansible dependencies
  apt: name={{item}}
  with_items: nodejs_packages

- name: Add APT repository
  apt_repository: repo={{nodejs_repository}}
  when: nodejs_repository != False

- name: Install nodejs
  apt: name=nodejs

# Latest packages doesn't have 'node' executable anymore
# It were renamed to 'nodejs'. Add link to support old
# cookbooks which use the legacy 'node' command.
- stat: path=/usr/bin/node
  register: node_bin

- name: Add legacy node link
  file: src=/usr/bin/nodejs dest=/usr/bin/node state=link
  when: not node_bin.stat.exists

---

- include_vars: "{{ansible_distribution}}.yml"

- name: Install Ansible dependencies
  apt: name={{item}}
  with_items: nodejs_packages

- name: Add APT repository
  apt_repository: repo={{nodejs_repository}}
  when: nodejs_repository != False

- name: Install nodejs
  apt: name=nodejs

- name: Install npm
  apt: name=npm

# Latest packages doesn't have 'node' executable anymore
# It were renamed to 'nodejs'. Add link to support old
# cookbooks which use the legacy 'node' command.
- stat: path=/usr/bin/node
  register: node_bin

- name: Add legacy node link
  file: src=/usr/bin/nodejs dest=/usr/bin/node state=link
  when: not node_bin.stat.exists

Install npm (was not installed on ubuntu trusty)
Install npm (was not installed on ubuntu trusty)