Skip to content

Instantly share code, notes, and snippets.

@dougstanley
Created June 30, 2017 16:00
Show Gist options
  • Save dougstanley/5a447bb03760f2e3b1b74f26dc382627 to your computer and use it in GitHub Desktop.
Save dougstanley/5a447bb03760f2e3b1b74f26dc382627 to your computer and use it in GitHub Desktop.
Snippet of ansible role to install latest node
---
- name: Get Node Distro
set_fact:
node_distro: "{{ ansible_lsb.codename }}"
when: ansible_lsb.codename != "stretch"
- name: Get Node Distro stretch
set_fact:
node_distro: "jessie"
when: ansible_lsb.codename == "stretch"
# Because the node repo doesn't have a stretch release yet, so
# on stretch we still use jessie release for node repo
- name: Add Nodesource Apt Key
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
id: 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280
state: present
when: ansible_os_family == "Debian"
become: yes
- name: Add Nodesource Repo
apt_repository:
repo: "deb https://deb.nodesource.com/node_6.x {{ node_distro }} main "
filename: nodesource
state: present
update_cache: yes
when: ansible_os_family == "Debian"
become: yes
tags:
- node
- name: install node system packages
apt: name={{ item }} state=latest install_recommends=no
with_items:
- nodejs
- npm
- grunt
when: ansible_os_family == "Debian"
become: yes
tags:
- node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment