--- - name: install required packages sudo: true apt: pkg={{ item }} with_items: - python-pycurl - apt-transport-https - name: add nodesource apt key sudo: true apt_key: > id=68576280 url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key state=present - name: add nodesource apt repository sudo: true template: > src=nodesource.list.j2 dest=/etc/apt/sources.list.d/nodesource.list owner=root group=root mode=644 register: result - name: apt-get update sudo: true apt: update_cache=yes when: result | changed - name: install package sudo: true apt: pkg=nodejs - name: generate ~/.npmrc template: > src=npmrc.j2 dest=~/.npmrc mode=0644 when: nodejs.npmrc|length > 0 - name: add `./node_modules/.bin` to PATH sudo: true copy: > content='export PATH="./node_modules/.bin:$PATH"' dest=/etc/profile.d/nodejs_path.sh mode=0644 when: nodejs.add_node_modules_bin_to_path