--- - name: Install dependencies sudo: yes apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 with_items: - git - curl - build-essential - libssl-dev - name: Detect nvm command: bash -lc "nvm --version" register: nvm_version ignore_errors: yes - name: Clone NVM git: repo=https://github.com/creationix/nvm.git dest=/opt/nvm when: nvm_version|failed - name: Create node dir for all users file: dest=/usr/local/node state=directory - name: Enable nvm for all users template: src=nvm.sh dest=/etc/profile.d/nvm.sh mode=755 - name: Detect node command: bash -lc "node -v" register: node_version ignore_errors: yes - name: Install node 4.2 LTS and make it default node command: bash -lc "nvm install 4.2 && nvm alias default 4.2" when: node_version|failed