---
- name: Ensure apt-transport-https is installed
  apt:
    pkg: ['apt-transport-https']
    state: latest
- name: Ensure the key is present
  apt_key:
    url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
- name: Add repository
  apt_repository:
    repo: 'deb https://deb.nodesource.com/node_12.x {{ ansible_distribution_release }} main'
    state: present
    filename: "nodesource"
- name: Add repository (SRC)
  apt_repository:
    repo: 'deb-src https://deb.nodesource.com/node_12.x {{ ansible_distribution_release }} main'
    state: present
    filename: "nodesource"
- name: Update apt
  apt:
    update_cache: yes
- name: Ensure nodejs is installed as root
  apt:
    pkg: ['nodejs']
    state: latest
- name: Ensure pm2 is present globally
  npm:
    name: pm2@latest
    global: yes
---
- name: Ensure apt-transport-https is installed
  apt:
    pkg: ['apt-transport-https']
    state: latest
- name: Ensure the key is present
  apt_key:
    url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
- name: Add repository
  apt_repository:
    repo: 'deb https://deb.nodesource.com/node_12.x {{ ansible_distribution_release }} main'
    state: present
    filename: "nodesource"
- name: Add repository (SRC)
  apt_repository:
    repo: 'deb-src https://deb.nodesource.com/node_12.x {{ ansible_distribution_release }} main'
    state: present
    filename: "nodesource"
- name: Update apt
  apt:
    update_cache: yes
- name: Ensure nodejs is installed as root
  apt:
    pkg: ['nodejs']
    state: latest
- name: Ensure pm2 is present globally
  npm:
    name: pm2@latest
    global: yes
- name: Install pm2 completion
  shell: pm2 completion install
Add pm2 completion for node role
Add pm2 completion for node role
