Skip to content

Commit

Permalink
Merge pull request #4 from f500/stretch
Browse files Browse the repository at this point in the history
Get latest LTS from nodesource.com
  • Loading branch information
ramondelafuente authored Jul 17, 2017
2 parents 5345446 + 2d42c50 commit 04cea97
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 34 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
------------------
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

nodejs_version: 6.x
10 changes: 7 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 0 additions & 4 deletions tasks/Debian-jessie.yml

This file was deleted.

4 changes: 0 additions & 4 deletions tasks/Debian-wheezy.yml

This file was deleted.

4 changes: 0 additions & 4 deletions tasks/Ubuntu.yml

This file was deleted.

36 changes: 22 additions & 14 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit 04cea97

Please sign in to comment.