Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Ansible Playbook Execution

on:
push:
branches:
- master
pull_request:
branches:
- master

permissions:
contents: read

jobs:
run-playbook-ubuntu-amd64:
runs-on: ubuntu-latest
strategy:
matrix:
ubuntu_version: [noble, jammy, focal]
node_version: [18.x, 20.x, 22.x]
container:
image: ubuntu:${{ matrix.ubuntu_version }}
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
apt-get update
apt-get install -y lsb-release sudo curl python3 python3-pip python3-venv
- name: Setup Virtual Environment
run: |
python3 -m venv venv
./venv/bin/pip install --upgrade pip
- name: Install Ansible and Requirements
run: |
./venv/bin/pip install -r requirements.txt
./venv/bin/pip install ansible
- name: Run Playbook
run: |
ANSIBLE_ROLES_PATH=../ ./venv/bin/ansible-playbook playbook.yml --extra-vars "nodejs_version=${{ matrix.node_version }}" --ask-become-pass
- name: Check Installed Node.js Version
shell: bash
run: |
NODE_VERSION_INSTALLED=$(node -v | cut -d. -f1 | sed 's/v//')
NODE_VERSION_EXPECTED=$(echo "${{ matrix.node_version }}" | cut -d. -f1)
if [[ "$NODE_VERSION_INSTALLED" != "$NODE_VERSION_EXPECTED" ]]; then
echo "Node.js version mismatch: expected $NODE_VERSION_EXPECTED, got $NODE_VERSION_INSTALLED"
exit 1
else
echo "Node.js version correctly installed: $NODE_VERSION_INSTALLED"
fi

run-playbook-debian-amd64:
runs-on: ubuntu-latest
strategy:
matrix:
debian_version: [bullseye, bookworm]
node_version: [18.x, 20.x, 22.x]
container:
image: debian:${{ matrix.debian_version }}
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
apt-get update
apt-get install -y lsb-release sudo curl python3 python3-pip python3-venv
- name: Setup Virtual Environment
run: |
python3 -m venv venv
./venv/bin/pip install --upgrade pip
- name: Install Ansible and Requirements
run: |
./venv/bin/pip install -r requirements.txt
./venv/bin/pip install ansible
- name: Run Playbook
run: |
ANSIBLE_ROLES_PATH=../ ./venv/bin/ansible-playbook playbook.yml --extra-vars "nodejs_version=${{ matrix.node_version }}" --ask-become-pass
- name: Check Installed Node.js Version
shell: bash
run: |
NODE_VERSION_INSTALLED=$(node -v | cut -d. -f1 | sed 's/v//')
NODE_VERSION_EXPECTED=$(echo "${{ matrix.node_version }}" | cut -d. -f1)
if [[ "$NODE_VERSION_INSTALLED" != "$NODE_VERSION_EXPECTED" ]]; then
echo "Node.js version mismatch: expected $NODE_VERSION_EXPECTED, got $NODE_VERSION_INSTALLED"
exit 1
else
echo "Node.js version correctly installed: $NODE_VERSION_INSTALLED"
fi

run-playbook-ubuntu-arm64:
runs-on: ubuntu-22.04-arm
strategy:
matrix:
ubuntu_version: [noble, jammy, focal]
node_version: [18.x, 20.x, 22.x]
container:
image: ubuntu:${{ matrix.ubuntu_version }}
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
apt-get update
apt-get install -y lsb-release sudo curl python3 python3-pip python3-venv
- name: Setup Virtual Environment
run: |
python3 -m venv venv
./venv/bin/pip install --upgrade pip
- name: Install Ansible and Requirements
run: |
./venv/bin/pip install -r requirements.txt
./venv/bin/pip install ansible
- name: Run Playbook
run: |
ANSIBLE_ROLES_PATH=../ ./venv/bin/ansible-playbook playbook.yml --extra-vars "nodejs_version=${{ matrix.node_version }}" --ask-become-pass
- name: Check Installed Node.js Version
shell: bash
run: |
NODE_VERSION_INSTALLED=$(node -v | cut -d. -f1 | sed 's/v//')
NODE_VERSION_EXPECTED=$(echo "${{ matrix.node_version }}" | cut -d. -f1)
if [[ "$NODE_VERSION_INSTALLED" != "$NODE_VERSION_EXPECTED" ]]; then
echo "Node.js version mismatch: expected $NODE_VERSION_EXPECTED, got $NODE_VERSION_INSTALLED"
exit 1
else
echo "Node.js version correctly installed: $NODE_VERSION_INSTALLED"
fi

run-playbook-debian-arm64:
runs-on: ubuntu-22.04-arm
strategy:
matrix:
debian_version: [bullseye, bookworm]
node_version: [18.x, 20.x, 22.x]
container:
image: debian:${{ matrix.debian_version }}
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
apt-get update
apt-get install -y lsb-release sudo curl python3 python3-pip python3-venv
- name: Setup Virtual Environment
run: |
python3 -m venv venv
./venv/bin/pip install --upgrade pip
- name: Install Ansible and Requirements
run: |
./venv/bin/pip install -r requirements.txt
./venv/bin/pip install ansible
- name: Run Playbook
run: |
ANSIBLE_ROLES_PATH=../ ./venv/bin/ansible-playbook playbook.yml --extra-vars "nodejs_version=${{ matrix.node_version }}" --ask-become-pass
- name: Check Installed Node.js Version
shell: bash
run: |
NODE_VERSION_INSTALLED=$(node -v | cut -d. -f1 | sed 's/v//')
NODE_VERSION_EXPECTED=$(echo "${{ matrix.node_version }}" | cut -d. -f1)
if [[ "$NODE_VERSION_INSTALLED" != "$NODE_VERSION_EXPECTED" ]]; then
echo "Node.js version mismatch: expected $NODE_VERSION_EXPECTED, got $NODE_VERSION_INSTALLED"
exit 1
else
echo "Node.js version correctly installed: $NODE_VERSION_INSTALLED"
fi
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

18 changes: 0 additions & 18 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MIT License (MIT)
=====================

Copyright (c) 2014 NodeSource and Mark Wolfe
Copyright (c) 2025 NodeSource
--------------------------------------------

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down
13 changes: 0 additions & 13 deletions Makefile

This file was deleted.

59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,71 @@
# ansible-nodejs-role

This is an Ansible role which adds the the NodeSource APT repository and installs Node.js.
This is an Ansible role that adds the NodeSource APT repository and installs Node.js.

Currently this role supports the following operating systems and releases.
## Supported Operating Systems

* **Ubuntu 14.04 LTS** (Trusty Tahr)
* **Ubuntu 16.04 LTS** (Xenial Xerus)
Currently, this role supports the following operating systems and releases:

- **Ubuntu 20.04 LTS** (Focal Fossa)
- **Ubuntu 22.04 LTS** (Jammy Jellyfish)
- **Ubuntu 24.04 LTS** (Noble Numbat)
- **Debian 11** (Bullseye)
- **Debian 12** (Bookworm)

## Usage

You can either:
### Install and Run Locally

To install and test this role locally, run:

```sh
ANSIBLE_ROLES_PATH=../ ansible-playbook playbook.yml --ask-become-pass
```

### Install via Ansible Galaxy

* Install the playbook via Ansible Galaxy:
You can install this role directly from Ansible Galaxy:

```text
$ ansible-galaxy install nodesource.node
```sh
ansible-galaxy install nodesource.node
```

* Install the using [requirements.yml via Ansible Galaxy](http://docs.ansible.com/ansible/galaxy.html#installing-multiple-roles-from-a-file):
Alternatively, use a `requirements.yml` file:

```yml
```yaml
- src: https://github.com/nodesource/ansible-nodejs-role
```

```text
$ ansible-galaxy install -r requirements.txt
Then install it using:

```sh
ansible-galaxy install -r requirements.yml
```

## Configure
## Configuration

Then configure it as follows:
Example playbook configuration:

```yaml
- hosts: servers
roles:
- nodesource.node
- nodesource.node
```

## Role Variables

- `nodejs_nodesource_pin_priority`: Pin-Priority of the NodeSource repository (default: `500`).
- `nodejs_version`: Set Node version (options: `0.10` or `0.12` or `4.6`, default: `4.6`)
- `nodejs_version`: Set the Node.js version (options: `18.x`, `20.x`, `22.x`, `23.x`, default: `22.x`).

## Testing

To test this role using [molecule](https://github.com/metacloud/molecule):

```
$ make
$ molecule test
```
This role is automatically tested using GitHub Actions. To see how the CI/CD pipeline is configured, check the `.github/workflows/ci.yml` file.

## Author

Mark Wolfe <mark@wolfe.id.au>
Originally developed by Mark Wolfe.
Maintained by NodeSource.

## License

This code is Copyright (c) 2014 NodeSource and Mark Wolfe and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included [LICENSE.md](./LICENSE.md) file for more details.
This code is licensed under the MIT License. See the included [LICENSE.md](./LICENSE.md) file for more details.
13 changes: 10 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
---
# 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"
- "23.x"
46 changes: 36 additions & 10 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
---
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
- name: Ubuntu
versions:
- focal
- jammy
- noble
- name: Debian
versions:
- bullseye
- bookworm
- name: EL
versions:
- "8"
- "9"
- "10"
- name: Fedora
versions:
- "39"
- "40"
- "41"
- name: GenericLinux
versions:
- all
categories:
- development
- networking
- packaging
- web
- development
- networking
- packaging
- web
- system
- infrastructure
- performance
- security
- databases
- cloud
dependencies: []
Loading