I'm looking for an appropriate Ansible Role or Ansible YAML file for installing NodeJS LTS on a Ubuntu 16.04.3 xenial system. I tried more than 10 Ansible roles from Galaxy but didn't find any of them working (throws error such as potentially dangerous to add this PPA etc.
.
Can anyone provide any Ansible playbook or suggest me a role to install NodeJS LTS on Ubuntu 16.04?
Here is the working example:
---
- hosts: all
gather_facts: yes
become: yes
vars:
NODEJS_VERSION: "8"
ansible_distribution_release: "xenial" #trusty
tasks:
- name: Install the gpg key for nodejs LTS
apt_key:
url: "https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
state: present
- name: Install the nodejs LTS repos
apt_repository:
repo: "deb https://deb.nodesource.com/node_{{ NODEJS_VERSION }}.x {{ ansible_distribution_release }} main"
state: present
update_cache: yes
- name: Install the nodejs
apt:
name: nodejs
state: present
Hope it will help you