ansible-nodejs/tasks/nodejs.yml

37 lines
1.2 KiB
YAML
Raw Permalink 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/
when: local_development.enabled == false
with_items: "{{ globally_installed_tools }}"