-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
124 additions
and
119 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
--- | ||
# Default Node.js version (can be overridden) | ||
nodejs_version: "22.x" | ||
|
||
# Pin-Priority of NodeSource repository | ||
nodejs_nodesource_pin_priority: 500 | ||
nodejs_nodesource_pin_priority: 600 | ||
|
||
# 0.10 or 0.12 or 4.x | ||
nodejs_version: "4.6" | ||
# List of supported Node.js versions | ||
nodejs_supported_versions: | ||
- "18.x" | ||
- "20.x" | ||
- "22.x" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,45 @@ | ||
--- | ||
galaxy_info: | ||
author: Mark Wolfe | ||
author: NodeSource | ||
namespace: nodesource | ||
role_name: ansible_nodejs_role | ||
description: Installs the NodeSource Node.js binary packages | ||
company: NodeSource | ||
license: MIT | ||
min_ansible_version: 1.2 | ||
min_ansible_version: "2.16" | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- precise | ||
- trusty | ||
categories: | ||
- development | ||
- networking | ||
- packaging | ||
- web | ||
- name: Ubuntu | ||
versions: | ||
- focal | ||
- jammy | ||
- noble | ||
- name: Debian | ||
versions: | ||
- buster | ||
- bullseye | ||
- bookworm | ||
- name: EL | ||
versions: | ||
- "8" | ||
- "9" | ||
- "10" | ||
- name: Fedora | ||
versions: | ||
- "39" | ||
- "40" | ||
- "41" | ||
- name: GenericLinux | ||
versions: | ||
- all | ||
categories: | ||
- development | ||
- networking | ||
- packaging | ||
- web | ||
- system | ||
- infrastructure | ||
- performance | ||
- security | ||
- databases | ||
- cloud | ||
dependencies: [] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
ansible==2.1 | ||
testinfra==1.3.0 | ||
molecule | ||
ansible==11.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
--- | ||
- name: Test the Node.js role | ||
hosts: all | ||
- name: Install Node.js using ansible-nodejs-role | ||
hosts: localhost | ||
connection: local | ||
become: yes | ||
roles: | ||
- role: "ansible-nodejs-role" | ||
- role: ansible-nodejs-role | ||
vars: | ||
nodejs_version: '4' | ||
nodejs_version: "18.x" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,71 @@ | ||
# Install Node.js using packages crafted by NodeSource | ||
--- | ||
- name: Ensure the system can use the HTTPS transport for APT | ||
stat: | ||
path: /usr/lib/apt/methods/https | ||
register: apt_https_transport | ||
|
||
- name: Install HTTPS transport for APT | ||
apt: | ||
pkg: apt-transport-https | ||
state: installed | ||
when: not apt_https_transport.stat.exists | ||
|
||
- name: Install GPG | ||
apt: | ||
pkg: gnupg | ||
state: installed | ||
|
||
- name: Import the NodeSource GPG key into apt | ||
apt_key: | ||
url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280 | ||
id: "68576280" | ||
state: present | ||
- name: Ensure selected Node.js version is valid | ||
ansible.builtin.assert: | ||
that: | ||
- nodejs_version in nodejs_supported_versions | ||
fail_msg: "Invalid Node.js version: {{ nodejs_version }}. Supported versions: {{ nodejs_supported_versions | join(', ') }}." | ||
|
||
- name: Add NodeSource deb repository | ||
apt_repository: | ||
repo: 'deb https://deb.nodesource.com/node_{{ debian_repo_version }} {{ ansible_distribution_release }} main' | ||
- name: Ensure required packages are installed | ||
ansible.builtin.apt: | ||
pkg: | ||
- ca-certificates | ||
- curl | ||
- gnupg | ||
state: present | ||
update_cache: yes | ||
|
||
- name: Add NodeSource deb-src repository | ||
apt_repository: | ||
repo: 'deb-src https://deb.nodesource.com/node_{{ debian_repo_version }} {{ ansible_distribution_release }} main' | ||
state: present | ||
- name: Ensure /usr/share/keyrings directory exists | ||
ansible.builtin.file: | ||
path: /usr/share/keyrings | ||
state: directory | ||
mode: "0755" | ||
|
||
- name: Add NodeSource repository preferences | ||
template: | ||
src: etc/apt/preferences.d/deb_nodesource_com_node.pref.2 | ||
dest: /etc/apt/preferences.d/deb_nodesource_com_node.pref | ||
- name: Remove old NodeSource GPG key (if exists) | ||
ansible.builtin.file: | ||
path: /usr/share/keyrings/nodesource.gpg | ||
state: absent | ||
|
||
- name: Install Node.js | ||
apt: | ||
pkg: | ||
- nodejs | ||
state: installed | ||
- name: Remove old NodeSource repository list (if exists) | ||
ansible.builtin.file: | ||
path: /etc/apt/sources.list.d/nodesource.list | ||
state: absent | ||
|
||
- name: Download and import NodeSource GPG key | ||
ansible.builtin.get_url: | ||
url: https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | ||
dest: /usr/share/keyrings/nodesource.gpg | ||
mode: "0644" | ||
register: gpg_download | ||
failed_when: gpg_download.failed | ||
|
||
- name: Detect system architecture | ||
ansible.builtin.command: dpkg --print-architecture | ||
register: system_arch | ||
changed_when: false | ||
|
||
- name: Ensure architecture is supported | ||
ansible.builtin.assert: | ||
that: | ||
- system_arch.stdout in ['amd64', 'arm64', 'armhf'] | ||
fail_msg: "Unsupported architecture: {{ system_arch.stdout }}. Only amd64, arm64, and armhf are supported." | ||
|
||
- name: Add NodeSource APT repository | ||
ansible.builtin.template: | ||
src: nodesource.list.j2 | ||
dest: /etc/apt/sources.list.d/nodesource.list | ||
mode: "0644" | ||
|
||
- name: Add package pinning for Node.js | ||
ansible.builtin.template: | ||
src: preferences.d/nodejs.j2 | ||
dest: /etc/apt/preferences.d/nodejs | ||
mode: "0644" | ||
|
||
- name: Update APT cache | ||
ansible.builtin.apt: | ||
update_cache: yes | ||
|
||
- name: Install Node.js | ||
ansible.builtin.apt: | ||
pkg: nodejs | ||
state: present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deb [arch={{ system_arch.stdout }} signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Package: nodejs | ||
Pin: origin deb.nodesource.com | ||
Pin-Priority: 600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
--- | ||
# vars file for nodejs | ||
debian_repo_version: "{{ nodejs_version if '4' not in nodejs_version else '4.x' }}" | ||
# Node.js version (override if needed) | ||
nodejs_version: "22.x" |