chore(ensure-nodejs-fork): downstream changes from ensure-nodejs
- Require node_version variable (the default has been removed).[1]
- Handle Node installations for all versions correctly.[2]
[1]: https://opendev.org/zuul/zuul-jobs/commit/e188ce71ca7361adfee668f8d17d0d78f360dc90
[2]: https://opendev.org/zuul/zuul-jobs/commit/efa55f881d6ee2681b008847372d69abf350ac21
Change-Id: Id1f5419aa49fc8ee631b2ba53389a4d982af7963
diff --git a/roles/ensure-nodejs-fork/tasks/main.yaml b/roles/ensure-nodejs-fork/tasks/main.yaml
index cc04519..0437edc 100644
--- a/roles/ensure-nodejs-fork/tasks/main.yaml
+++ b/roles/ensure-nodejs-fork/tasks/main.yaml
@@ -1,3 +1,7 @@
+- name: Ensure we know what version of node to install
+ assert:
+ that: node_version is defined
+
- name: Update apt cache
apt:
update_cache: yes
@@ -21,10 +25,21 @@
name: ensure-package-repositories
vars:
repositories_keys:
+ - url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
+ repositories_list:
+ - repo: deb-src https://deb.nodesource.com/node_{{ node_version }}.x {{ ansible_distribution_release }} main
+ - repo: deb https://deb.nodesource.com/node_{{ node_version }}.x {{ ansible_distribution_release }} main
+ when: node_version | int < 16
+
+- name: Add all repositories
+ include_role:
+ name: ensure-package-repositories
+ vars:
+ repositories_keys:
- url: https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key
repositories_list:
- - repo: deb-src https://deb.nodesource.com/node_{{ node_version }}.x nodistro main
- repo: deb https://deb.nodesource.com/node_{{ node_version }}.x nodistro main
+ when: node_version | int >= 16
# Use template so that we can easily update this in the future to be able to
# use a mirror location.