Update to support deb11
- Remove apt_key, switch to copying dearmored key
- Add ability to globally install npm modules
Metadata fixes for ansible galaxy support
Change-Id: Ic3873cf0e491cb91e3e6891f1f85409901e38f8d
diff --git a/.reuse/dep5 b/.reuse/dep5
index f73f9f8..8d8b592 100644
--- a/.reuse/dep5
+++ b/.reuse/dep5
@@ -1,9 +1,9 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Files: .cookiecutter_params.json VERSION .gitreview
+Files: .cookiecutter_params.json VERSION .gitreview README.md
Copyright: 2020 Open Networking Foundation
License: Apache-2.0
-Files: files/nodesource.gpg.key
+Files: files/nodesource-archive-keyring.gpg
Copyright: 2020 NodeSource
License: MIT
diff --git a/Makefile b/Makefile
index 34deb3e..2dba580 100644
--- a/Makefile
+++ b/Makefile
@@ -23,10 +23,13 @@
-d "{extends: default, rules: {line-length: {max: 99}}}" \
-s $(YAML_FILES)
+# List of molecule files, not including base molecule.yml which isn't ansible format
+MOLECULE_FILES ?= $(shell find molecule -type f -name '*.yml' \! -name 'molecule.yml' -print )
+
ansiblelint: ## lint check with ansible-lint
ansible-lint --version
ansible-lint -v .
- ansible-lint -v molecule/*/*
+ ansible-lint -v $(MOLECULE_FILES)
license: ## Check license with the reuse tool
reuse --version
diff --git a/README.md b/README.md
index f243b26..7ff736a 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,16 @@
-<!--
-SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
-SPDX-License-Identifier: Apache-2.0
---!>
# nodejs
Node.js installed via NodeSource Binary Distribution
-Only configuration knob is the `nodejs_version`, which should be specified in
-the format described in the [NodeSource binary distribution
-docs](https://github.com/nodesource/distributions).
+Configuration options:
-## Requirements
-Minimum ansible version: 2.9.5
+- `nodejs_version`: version of NodeJS specified in the format described in the
+ [NodeSource binary distribution
+ docs](https://github.com/nodesource/distributions). Default is 12.x
+
+- `nodejs_npm_modules`: list of globally installed npm packages. Currently
+ installs the newest versions.
## Example Playbook
diff --git a/defaults/main.yml b/defaults/main.yml
index 110e758..42caffa 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -5,3 +5,6 @@
# SPDX-License-Identifier: Apache-2.0
nodejs_version: "node_12.x"
+
+nodejs_npm_modules:
+ - "bower"
diff --git a/files/nodesource-archive-keyring.gpg b/files/nodesource-archive-keyring.gpg
new file mode 100644
index 0000000..4f3ec4e
--- /dev/null
+++ b/files/nodesource-archive-keyring.gpg
Binary files differ
diff --git a/files/nodesource.gpg.key b/files/nodesource.gpg.key
deleted file mode 100644
index 1dc1d10..0000000
--- a/files/nodesource.gpg.key
+++ /dev/null
@@ -1,52 +0,0 @@
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: GnuPG v1
-Comment: GPGTools - https://gpgtools.org
-
-mQINBFObJLYBEADkFW8HMjsoYRJQ4nCYC/6Eh0yLWHWfCh+/9ZSIj4w/pOe2V6V+
-W6DHY3kK3a+2bxrax9EqKe7uxkSKf95gfns+I9+R+RJfRpb1qvljURr54y35IZgs
-fMG22Np+TmM2RLgdFCZa18h0+RbH9i0b+ZrB9XPZmLb/h9ou7SowGqQ3wwOtT3Vy
-qmif0A2GCcjFTqWW6TXaY8eZJ9BCEqW3k/0Cjw7K/mSy/utxYiUIvZNKgaG/P8U7
-89QyvxeRxAf93YFAVzMXhoKxu12IuH4VnSwAfb8gQyxKRyiGOUwk0YoBPpqRnMmD
-Dl7SdmY3oQHEJzBelTMjTM8AjbB9mWoPBX5G8t4u47/FZ6PgdfmRg9hsKXhkLJc7
-C1btblOHNgDx19fzASWX+xOjZiKpP6MkEEzq1bilUFul6RDtxkTWsTa5TGixgCB/
-G2fK8I9JL/yQhDc6OGY9mjPOxMb5PgUlT8ox3v8wt25erWj9z30QoEBwfSg4tzLc
-Jq6N/iepQemNfo6Is+TG+JzI6vhXjlsBm/Xmz0ZiFPPObAH/vGCY5I6886vXQ7ft
-qWHYHT8jz/R4tigMGC+tvZ/kcmYBsLCCI5uSEP6JJRQQhHrCv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
-xxECi0l/BzNxeU1gK88hEaNjIfviPR/h6Gq6KOcNKZ8rVFdwFpjbvwHMQBWhrqfu
-G3KaePvbnObKHXpfIKoAM7X2qfO+IFnLGTPyhFTcrl6vZBTMZTfZiC1XDQLuGUnd
-sckuXINIU3DFWzZGr0QrqkuE/jyr7FXeUJj9B7cLo+s/TXo+RaVfi3kOc9BoxIvy
-/qiNGs/TKy2/Ujqp/affmIMoMXSozKmga81JSwkADO1JMgUy6dApXz9kP4EE3g==
-=CLGF
------END PGP PUBLIC KEY BLOCK-----
diff --git a/meta/main.yml b/meta/main.yml
index 7fcee3b..18a96ce 100644
--- a/meta/main.yml
+++ b/meta/main.yml
@@ -5,6 +5,9 @@
# SPDX-License-Identifier: Apache-2.0
galaxy_info:
+ role_name: nodejs
+ namespace: onf
+
author: Open Networking Foundation
description: Node.js installed via NodeSource Binary Distribution
company: Open Networking Foundation
@@ -21,7 +24,7 @@
- "18.04"
- name: Debian
versions:
- - "10"
+ - "11"
galaxy_tags:
- nodejs
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
index f556f9e..205828f 100644
--- a/molecule/default/molecule.yml
+++ b/molecule/default/molecule.yml
@@ -14,8 +14,8 @@
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:ro"
- - name: "debian-10-priv"
- image: "quay.io/paulfantom/molecule-systemd:debian-10"
+ - name: "debian-11-priv"
+ image: "onfinfra/molecule-systemd:debian-11"
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:ro"
diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml
index 2c81204..0f916c0 100644
--- a/molecule/default/verify.yml
+++ b/molecule/default/verify.yml
@@ -10,12 +10,13 @@
- name: Check installed Node.js version string
command:
- cmd: "nodejs --version"
+ cmd: "node --version"
register: nodejs_version
tags:
- skip_ansible_lint # info gathering
- - debug:
+ - name: Check installed Node.js version number
+ debug:
var: nodejs_version
- name: Assert that installed Node.js version matches version string
diff --git a/tasks/Debian.yml b/tasks/Debian.yml
index af47585..216d6c6 100644
--- a/tasks/Debian.yml
+++ b/tasks/Debian.yml
@@ -4,20 +4,33 @@
# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
# SPDX-License-Identifier: Apache-2.0
-- name: Add NodeSource apt repo key
- apt_key:
- data: "{{ lookup('file','nodesource.gpg.key') }}"
- state: "present"
+- name: Copy Nodesource repo GPG key
+ ansible.builtin.copy:
+ src: nodesource-archive-keyring.gpg
+ dest: /usr/share/keyrings/nodesource-archive-keyring.gpg
+ owner: root
+ group: root
+ mode: 0644
- name: Add NodeSource apt repo
apt_repository:
- repo: "deb https://deb.nodesource.com/{{ nodejs_version }} {{ ansible_lsb['codename'] }} main"
+ repo: >-
+ deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource-archive-keyring.gpg]
+ https://deb.nodesource.com/{{ nodejs_version }} {{ ansible_lsb['codename'] }} main
mode: "0600"
update_cache: true
- name: Install Node.js
apt:
- name: "nodejs"
+ name:
+ - "nodejs"
state: "present"
update_cache: true
cache_valid_time: 3600
+
+- name: Install global npm tools
+ community.general.npm:
+ global: true
+ state: "present"
+ name: "{{ item }}"
+ with_items: "{{ nodejs_npm_modules }}"