- name: Install NodeJS
  apt: pkg=nodejs state=installed

- name: Symlink nodejs to node for legacy applications
  file: src=/usr/bin/nodejs dest=/usr/bin/node state=link

- name: Install NodeJS's package manager
  apt: pkg=npm state=installed

- name: Install PhantomJS
  apt: pkg=phantomjs state=installed

- name: Install useful npm modules
  shell: npm -g install {{ item }}
  with_items:
    - casperjs
    - slimerjs
    - jshint
- name: Install NodeJS
  apt: pkg=nodejs state=installed

- name: Symlink nodejs to node for legacy applications
  file: src=/usr/bin/nodejs dest=/usr/bin/node state=link

- name: Install NodeJS's package manager
  apt: pkg=npm state=installed

- name: Install PhantomJS
  apt: pkg=phantomjs state=installed

- name: Install useful npm modules
  npm: name={{ item }} global=yes state=present
  with_items:
    - casperjs
    - slimerjs
    - jshint
Use Ansible's npm module rather than shell.
Use Ansible's npm module rather than shell.

This makes it run a lot faster - running "npm -g install" for each item
was really slow. This allows us to short circuit that because it's
already installed now.
