From 2d42c5018f1c139e468e0c469d7475ff9cf2e417 Mon Sep 17 00:00:00 2001 From: "Jasper N. Brouwer" Date: Fri, 14 Jul 2017 21:23:59 +0200 Subject: [PATCH] Get latest LTS from nodesource.com --- README.md | 19 ++++++++++++++----- defaults/main.yml | 3 +++ meta/main.yml | 10 +++++++--- tasks/Debian-jessie.yml | 4 ---- tasks/Debian-wheezy.yml | 4 ---- tasks/Ubuntu.yml | 4 ---- tasks/main.yml | 36 ++++++++++++++++++++++-------------- 7 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 defaults/main.yml delete mode 100644 tasks/Debian-jessie.yml delete mode 100644 tasks/Debian-wheezy.yml delete mode 100644 tasks/Ubuntu.yml diff --git a/README.md b/README.md index 360d0f9..8ba32f7 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,33 @@ Nodejs -======== +====== -Install Nodejs and the NPM package manager +Install Node.js and NPM Requirements ------------ -Debian Wheezy with the package python-pycurl and python-software-properties installed. +Debian Wheezy/Jessie/Stretch or Ubuntu Precise/Trusty/Xenial. + +Role Variables +-------------- + +Specify the version of Node.js you want: + + nodejs_version: 6.x + +See https://github.com/nodesource/distributions Example Playbook ------------------------- - hosts: servers roles: - - { role: f500.nodejs } + - { role: f500.nodejs } License ------- -LGPL +LGPL-3.0 Author Information ------------------ diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..51bf3d6 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +nodejs_version: 6.x diff --git a/meta/main.yml b/meta/main.yml index 0ffd876..d342578 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,17 +1,21 @@ --- galaxy_info: author: Jasper N. Brouwer, Ramon de la Fuente - description: Install nodejs and npm + description: Install Node.js and NPM company: Future500 - license: LGPL + license: LGPL-3.0 min_ansible_version: 1.4 platforms: - name: Debian versions: - wheezy + - jessie + - stretch - name: Ubuntu versions: - - all + - precise + - trusty + - xenial categories: - web - system diff --git a/tasks/Debian-jessie.yml b/tasks/Debian-jessie.yml deleted file mode 100644 index 5a7f991..0000000 --- a/tasks/Debian-jessie.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- - -- name: install nodejs (Debian-jessie) - apt: pkg=nodejs-legacy default_release=jessie-backports state=present diff --git a/tasks/Debian-wheezy.yml b/tasks/Debian-wheezy.yml deleted file mode 100644 index c8ffb9f..0000000 --- a/tasks/Debian-wheezy.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- - -- name: install nodejs (Debian-wheezy) - apt: pkg=nodejs-legacy default_release=wheezy-backports state=present diff --git a/tasks/Ubuntu.yml b/tasks/Ubuntu.yml deleted file mode 100644 index b90052e..0000000 --- a/tasks/Ubuntu.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- - -- name: install nodejs (Ubuntu) - apt: pkg=nodejs state=present \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 1801c5b..c4f8e90 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,27 +1,35 @@ --- -# Install nodejs (Debian) -- include: Debian-wheezy.yml - when: (ansible_distribution == "Debian" and ansible_distribution_release == "wheezy") -- include: Debian-jessie.yml - when: (ansible_distribution == "Debian" and ansible_distribution_release == "jessie") -# Install nodejs (Ubuntu) -- include: Ubuntu.yml - when: ansible_distribution in ['Ubuntu'] +- name: Add the nodesource.com trusted key + apt_key: + id: 68576280 + url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key +- name: Add the nodesource.com repository + apt_repository: + repo: "deb https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main" + update_cache: no -- name: install npm - shell: curl -L https://www.npmjs.com/install.sh | bash creates=/usr/bin/npm +- name: Add the nodesource.com source repository + apt_repository: + repo: "deb-src https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main" + update_cache: yes -- name: get temp directory +- name: Install Node.js & NPM + apt: + name: nodejs + +- name: Check temp directory command: npm -g config get tmp register: npm_tmp_dir changed_when: False -- name: set temp directory +- name: Set temp directory command: npm -g config set tmp /tmp when: npm_tmp_dir.stdout != '/tmp' -- name: remove old temp directory - file: "path={{ npm_tmp_dir.stdout }} state=absent" +- name: Remove old temp directory + file: + path: "{{ npm_tmp_dir.stdout }}" + state: absent when: npm_tmp_dir.stdout != '/tmp'