Last Updated: February 25, 2016
·
12.02K
· Lorin Hochstein

Install node on ubuntu using ansible

The official Node docs recommend using a curlpipe, but I prefer using Ansible explicitly isntead.

- name: install nodejs
   hosts: yourhostshere
   gather_facts: True
   sudo: True
   tasks:
     - name: add apt key for nodesource
      apt_key: url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key

    - name: add repo for nodesource
      apt_repository:
            repo: 'deb https://deb.nodesource.com/node_0.10 {{ ansible_distribution_release }} main' 
            update_cache: yes

    - name: install nodejs
      apt: name=nodejs