From 45fe96382b8910135c456630b817f057037e668d Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sun, 30 Dec 2018 15:33:04 +0000 Subject: [PATCH] Pin nodejs package to upstream repo In the case where a node_version is less than what's in the distro, we'll wind up installing distro packages instead of upstream packages which will either fail due to binary path naming issues, or succeed but install a different version of nodejs than was requested. Pin the package to the nodesource repo. Put the file in as a template, as we should really update this role to be able to optionally make use of a local mirror, in which case the file will need to jinja. Change-Id: If313d895a73bd2be7f598179a51b6485a37000ba --- roles/install-nodejs/tasks/main.yaml | 11 +++++++++++ roles/install-nodejs/templates/nodejs.pref.j2 | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 roles/install-nodejs/templates/nodejs.pref.j2 diff --git a/roles/install-nodejs/tasks/main.yaml b/roles/install-nodejs/tasks/main.yaml index 84dcd1dde..310d8e5a9 100644 --- a/roles/install-nodejs/tasks/main.yaml +++ b/roles/install-nodejs/tasks/main.yaml @@ -27,6 +27,17 @@ 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 diff --git a/roles/install-nodejs/templates/nodejs.pref.j2 b/roles/install-nodejs/templates/nodejs.pref.j2 new file mode 100644 index 000000000..c83050692 --- /dev/null +++ b/roles/install-nodejs/templates/nodejs.pref.j2 @@ -0,0 +1,3 @@ +Package: nodejs +Pin: origin deb.nodesource.com +Pin-Priority: 900