From 7ea6d1198177c87987be5e23c215fd151482d0da Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Sat, 4 Apr 2020 15:51:27 -0400 Subject: [PATCH] ensure-nodejs: refactor to use ensure-package-repositories This patch refactors ensure-nodejs to use the new generic role to allow it to be cross-platform in the future. Change-Id: I859b6b3e33bc22ad4f99828e921ac2ed35a49252 --- roles/ensure-nodejs/tasks/main.yaml | 26 +++++++++----------------- zuul-tests.d/js-roles-jobs.yaml | 1 + 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/roles/ensure-nodejs/tasks/main.yaml b/roles/ensure-nodejs/tasks/main.yaml index 553099f0c..86a246e66 100644 --- a/roles/ensure-nodejs/tasks/main.yaml +++ b/roles/ensure-nodejs/tasks/main.yaml @@ -15,23 +15,15 @@ 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 +- name: Add all repositories + include_role: + 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 # Use template so that we can easily update this in the future to be able to # use a mirror location. diff --git a/zuul-tests.d/js-roles-jobs.yaml b/zuul-tests.d/js-roles-jobs.yaml index 0f7624c31..c6530c8d5 100644 --- a/zuul-tests.d/js-roles-jobs.yaml +++ b/zuul-tests.d/js-roles-jobs.yaml @@ -3,6 +3,7 @@ description: Test the ensure-nodejs role files: - roles/ensure-nodejs/.* + - roles/ensure-package-repositories/.* run: test-playbooks/simple-role-test.yaml vars: role_name: ensure-nodejs