Rename install-nodejs to ensure-nodejs for consistency

The old role will be kept and include ensure-nodejs for backwards-compatability.

Change-Id: Ib4cf74d6c1e8774f6fc37d6a30f690eb8f9f3d08
This commit is contained in:
vass 2020-04-01 19:53:01 +02:00 committed by Mohammed Naser
parent ff44b6cd4e
commit ac72b44911
11 changed files with 86 additions and 73 deletions

View File

@ -2,6 +2,7 @@ Javascript Roles
================
.. zuul:autorole:: ensure-javascript-packages
.. zuul:autorole:: ensure-nodejs
.. zuul:autorole:: fetch-javascript-content-tarball
.. zuul:autorole:: fetch-javascript-output
.. zuul:autorole:: fetch-javascript-tarball

View File

@ -1,5 +1,5 @@
- hosts: all
roles:
- install-nodejs
- ensure-nodejs
- install-yarn
- ensure-javascript-packages

View File

@ -1,5 +1,5 @@
- name: Ensure Markdownlint is installed via NPM
hosts: all
roles:
- install-nodejs
- ensure-nodejs
- ensure-markdownlint

View File

@ -0,0 +1,6 @@
Install NodeJS from nodesource
**Role Variables**
.. zuul:rolevar:: node_version
:default: 6

View File

@ -0,0 +1,2 @@
---
node_version: 6

View File

@ -0,0 +1,3 @@
Package: nodejs
Pin: origin deb.nodesource.com
Pin-Priority: 900

View File

@ -0,0 +1,60 @@
- 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

View File

@ -0,0 +1,3 @@
Package: nodejs
Pin: origin deb.nodesource.com
Pin-Priority: 900

View File

@ -1,6 +1 @@
Install NodeJS from nodesource
**Role Variables**
.. zuul:rolevar:: node_version
:default: 6
.. warning:: Deprecated, use ensure-nodejs instead.

View File

@ -1,60 +1,3 @@
- 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
- name: Include ensure-nodejs.
include_role:
name: ensure-nodejs

View File

@ -1,11 +1,11 @@
- job:
name: zuul-jobs-test-install-nodejs
description: Test the install-nodejs role
name: zuul-jobs-test-ensure-nodejs
description: Test the ensure-nodejs role
files:
- roles/install-nodejs/.*
- roles/ensure-nodejs/.*
run: test-playbooks/simple-role-test.yaml
vars:
role_name: install-nodejs
role_name: ensure-nodejs
- job:
@ -35,7 +35,7 @@
- project:
check:
jobs: &id001
- zuul-jobs-test-install-nodejs
- zuul-jobs-test-ensure-nodejs
- zuul-jobs-test-fetch-javascript-tarball
- zuul-jobs-test-fetch-javascript-tarball-synchronize
gate: