zuul-jobs/roles/ensure-nodejs/tasks/main.yaml
vass ac72b44911 Rename install-nodejs to ensure-nodejs for consistency
The old role will be kept and include ensure-nodejs for backwards-compatability.

Change-Id: Ib4cf74d6c1e8774f6fc37d6a30f690eb8f9f3d08
2020-04-04 15:41:29 -04:00

61 lines
1.4 KiB
YAML

- name: Update apt cache
apt:
update_cache: yes
become: yes
- name: Install prereqs
package:
name: apt-transport-https
state: present
become: yes
- name: Pin nodejs installs to nodesource
copy:
src: 00-nodesource.pref
dest: /etc/apt/preferences.d/00-nodesource.pref
become: yes
- name: Add nodesource repository key
apt_key:
url: "https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
become: yes
- name: Add nodesource apt source repository
apt_repository:
repo: "deb-src https://deb.nodesource.com/node_{{ node_version }}.x {{ ansible_distribution_release }} main"
state: present
become: yes
- name: Add nodesource apt repository
apt_repository:
repo: "deb https://deb.nodesource.com/node_{{ node_version }}.x {{ ansible_distribution_release }} main"
state: present
update_cache: yes
become: yes
# Use template so that we can easily update this in the future to be able to
# use a mirror location.
- name: Pin NodeJS to nodesource apt repository
become: yes
template:
dest: /etc/apt/preferences.d/nodejs.pref
group: root
mode: 0644
owner: root
src: nodejs.pref.j2
- name: Install NodeJS from nodesource
package:
name: nodejs
state: latest
become: yes
tags:
# Ignore ANSIBLE0010: We really want latest version
- skip_ansible_lint
- name: Output node version
command: node --version
- name: Output npm version
command: npm --version