ansible-nodejs/tasks/nodejs.yml

36 lines
1.1 KiB
YAML
Raw Normal View History

---
- name: install systems to help setup nodejs
apt: pkg={{ item }} state=present
with_items:
- python-apt
- git
- apt-transport-https
- name: add the nodesource repository
apt_key: url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key state=present
- name: add the nodesource binary repository
apt_repository:
repo="deb https://deb.nodesource.com/node_{{ node_version_family }} {{ ansible_lsb.codename }} main"
state=present
- name: add the nodesource source repository
apt_repository:
repo="deb-src https://deb.nodesource.com/node_{{ node_version_family }} {{ ansible_lsb.codename }} main"
state=present update_cache=yes
- name: install nodejs + npm
apt: pkg=nodejs state=present
- name: check if nodejs binary exists and needs linking to node binary
stat: path=/usr/bin/nodejs
register: nodejs_bin
- name: link nodejs binary correctly
file: src=/usr/bin/nodejs dest=/usr/bin/node state=link
when: nodejs_bin.stat.exists
- name: install globally required tools
npm: name={{ item }} global=yes state=present registry=http://registry.npmjs.org/
with_items: {{ globally_installed_tools }}