16 Commits

Author SHA1 Message Date
greg db69e437d5 Remove sanitize node script and pre-commit hook
This is no longer needed with the properly set allowed attributes
2026-07-11 20:08:58 +02:00
greg 663c4da0a0 Update the prometheus-1 node after running Chef
It now contains the attributes from the ohai plugin
2026-07-11 17:35:04 +02:00
greg 010e2d0d64 Add zerotier ohai plugin to the base role 2026-07-11 17:34:39 +02:00
greg 065eac06b1 Add a recipe to install the zerotier ohai plugin
The attributes are saved as "automatic" attributes and look like this:

  "zerotier": {
    "version": "1.16.2",
    "node_id": "NODEID",
    "networks": {
      "NETWORKID": {
        "network_name": "networkname",
        "mac": "ff:ff:ff:ff:ff:ff",
        "status": "OK",
        "type": "PRIVATE",
        "interface": "abcdefg",
        "addresses": [
          "10.1.1.255/24"
        ]
      }
    }
  }

Refs #263
2026-07-11 17:29:31 +02:00
greg 1759af98b8 Simplify and improve chef attribute handling
Set the attributes in a Ruby file under /etc/chef/client.d/ instead of
editing /etc/chef/client.rb
Now uses the new whitelist attribute:
https://docs.chef.io/client/19/cookbooks/attributes/attribute_persistence/

Local chef config also uses the same file. That means there is no longer
a need to use the sanitize script to remove override and default
attributes from nodes.
2026-07-11 17:28:03 +02:00
raucao 736d4effa4 Upgrade RS discourse, increase service timeouts 2026-07-10 11:30:11 +02:00
raucao 1ebe0e4074 Merge pull request 'Update akkounts cookbook, deploy new akkounts VM' (#645) from chore/akkounts into master
Reviewed-on: #645
2026-07-10 09:29:44 +00:00
raucao 9250b2c726 Deploy new akkounts node, remove old one 2026-07-10 11:27:01 +02:00
raucao 6807b8f5bc Update akkounts cookbook, deploy new akkounts VM
* Fix: add missing directory resource
* New nodejs cookbook usage
* Remove Redis entirely (not using local Redis anymore)
2026-07-10 11:24:42 +02:00
raucao 0338e56d4c Merge pull request 'Upgrade nodejs cookbook from 7.3 to 11.0' (#644) from chore/upgrade_nodejs_cookbook into master
Reviewed-on: #644
2026-07-10 09:23:02 +00:00
raucao bd193567ca Upgrade nodejs cookbook from 7.3 to 11.0 2026-07-10 11:19:43 +02:00
raucao 86f7b68726 Merge pull request 'Set up Prometheus and Alertmanager' (#632) from feature/prometheus_cookbook into master
Reviewed-on: #632
2026-07-09 13:33:38 +00:00
greg 51af9c76e0 Fix node attribute 2026-07-09 15:30:38 +02:00
greg f15d5cb958 Move the alertmanager port to an attribute 2026-07-09 15:23:46 +02:00
greg ae14a1f353 Move the node_exporter port to an attribute 2026-07-09 15:18:06 +02:00
raucao b700baac37 Configure alerts for disk/filesystem usage, memory, CPU 2026-07-09 14:04:27 +02:00
69 changed files with 1201 additions and 1124 deletions
+2 -22
View File
@@ -8,27 +8,7 @@ data_bag_path "data_bags"
encrypted_data_bag_secret "#{current_dir}/encrypted_data_bag_secret"
local_mode true # Chef local mode, replacing Solo
# Knife-Zero config, see https://knife-zero.github.io/40_configuration/
# Prevent attributes from being saved to the node files
knife[:automatic_attribute_whitelist] = %w[
fqdn
os
os_version
hostname
ipaddress
roles
recipes
ipaddress
platform
platform_version
cloud
cloud_v2
chef_packages
]
# Added to /etc/chef/client.rb on node bootstrap
# https://docs.chef.io/attribute_persistence/
# Source of truth: site-cookbooks/kosmos-base/files/default/chef_normal_attributes.yml
normal_attrs = YAML.load_file(File.expand_path("../site-cookbooks/kosmos-base/files/default/chef_normal_attributes.yml", __dir__))
knife[:normal_attribute_allowlist] = normal_attrs
knife[:allowed_normal_attributes] = normal_attrs
# Source of truth: site-cookbooks/kosmos-base/files/default/chef_attributes.rb
client_d_dir(File.expand_path("../site-cookbooks/kosmos-base/files/default/chef_attributes.rb"))
-40
View File
@@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT="$(git rev-parse --show-toplevel)/scripts/util/sanitize_node.sh"
FILES=$(git diff --cached --name-only --diff-filter=ACM -- 'nodes/*.json' || true)
[[ -z "$FILES" ]] && exit 0
DIRTY=0
while IFS= read -r file; do
staged_tmp=$(mktemp)
sanitized_tmp=$(mktemp)
# 1. get staged version
git show ":$file" > "$staged_tmp"
# 2. sanitize IN PLACE (on temp copy)
cp "$staged_tmp" "$sanitized_tmp"
"$SCRIPT" "$sanitized_tmp"
# 3. if sanitizer changed file, update working tree
if ! diff -q "$staged_tmp" "$sanitized_tmp" >/dev/null; then
cp "$sanitized_tmp" "$file"
echo "Sanitized: $file"
DIRTY=1
fi
rm -f "$staged_tmp" "$sanitized_tmp"
done <<< "$FILES"
if [[ "$DIRTY" -ne 0 ]]; then
echo ""
echo "Commit paused, sanitized files must be re-staged."
exit 1
fi
exit 0
+1 -1
View File
@@ -31,7 +31,7 @@ cookbook 'java', '~> 4.3.0'
cookbook 'logrotate', '= 2.2.0'
cookbook 'mysql', '~> 8.7.3'
cookbook 'nginx', '= 9.0.0'
cookbook 'nodejs', '~> 7.3.1'
cookbook 'nodejs', '~> 11.0.1'
cookbook 'ntp', '= 3.4.0'
cookbook 'ohai', '~> 5.2.5'
cookbook 'openssl', '~> 8.5.5'
+3 -2
View File
@@ -24,7 +24,7 @@ DEPENDENCIES
ref: nginx
mysql (~> 8.7.3)
nginx (= 9.0.0)
nodejs (~> 7.3.1)
nodejs (~> 11.0.1)
ntp (= 3.4.0)
ohai (~> 5.2.5)
openssl (~> 8.5.5)
@@ -86,9 +86,10 @@ GRAPH
build-essential (>= 5.0)
ohai (>= 4.1.0)
yum-epel (>= 0.0.0)
nodejs (7.3.3)
nodejs (11.0.1)
ark (>= 2.0.2)
chocolatey (>= 3.0)
yum (>= 7.2)
ntp (3.4.0)
ohai (5.2.5)
openssl (8.5.5)
-4
View File
@@ -28,10 +28,6 @@ Clone this repository, `cd` into it, and run:
bundle install
### Enable Git hooks
git config core.hooksPath .githooks
## Common tasks
### Bootstrap a new host server
-4
View File
@@ -1,4 +0,0 @@
{
"name": "akkounts-1",
"public_key": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0LKcqydrG3zgtmThEg+q\nOcw8QvIB2usMkF4kNMFeqhhdr2q/AtRcq4RJ0u0MiZbkHduGWfG9QZpjmbFZcEke\nURJbddqSDPHFAtrK2+BpcMqNN/mSp59f4MJf6wdLnBoeZCF5pCCXibyj+/754Ly+\nEJNiB1sf1Lu82YW2YM7iLhOLk1QQD2DTfBGbj9swdPrgKK+1npQ4A7O8sOB5gDjb\n9QVLCvCEoYFi+9is0vw/YryEr6tfnNw+CroP2uDfyVfWznF8oPUuttAcHgqDA3CV\n7lCRk9yVt1FKwuq2lFcsMqZ7wO4EoxpzCz/XTnpFPFvgeVinyXjSPsQCBAdwJe5T\nWQIDAQAB\n-----END PUBLIC KEY-----\n"
}
+4
View File
@@ -0,0 +1,4 @@
{
"name": "akkounts-2",
"public_key": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAi/0X3npRvDRwPVRIWu4z\nY+9Qnj7EONuarsZ5aVuuVV/sqUpdJoQB/zYCxrF3HvNXbaDDOmIKiUiTfttWdcVK\nOIXH1IcykFSXFzT5tBof+kRVTHIVp5vtR1dAi1eCm1i7CId52Zqti0aF2/08XVUy\npWOJLlDObwn/M6i0gAQs/kGtYkFhlvZrmAkrlDYCzHb1nalyATohS9n/aNn8bvY1\noSPZb4vmlW4ln5y+tqJf8fOWlfUiIdgRnsQKFa97ijfQFbv1TGv33rhqDdsjR2jn\n7qJmYQ7U83W2cGhBiUR7N4rWY0Mig3e9UeOufVpNDLVvRcXZWx1pzDyn9pD6lk+7\nFwIDAQAB\n-----END PUBLIC KEY-----\n"
}
+12
View File
@@ -0,0 +1,12 @@
config:
ul-indent: false # MD007
line-length: false # MD013
no-duplicate-heading: false # MD024
reference-links-images: false # MD052
ul-style:
style: asterisk
no-multiple-blanks:
maximum: 2
ignores:
- .github/copilot-instructions.md
- .windsurf/**
@@ -0,0 +1,3 @@
{
".": "11.0.1"
}
+261 -126
View File
@@ -1,221 +1,356 @@
# NodeJS Cookbook Changelog
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
## [11.0.1](https://github.com/sous-chefs/nodejs/compare/v11.0.0...v11.0.1) (2026-07-09)
### Bug Fixes
* migrate to Policyfile ([#315](https://github.com/sous-chefs/nodejs/issues/315)) ([0a481e2](https://github.com/sous-chefs/nodejs/commit/0a481e22c2dcb811800219f96d24ba95bca583da))
## [11.0.0](https://github.com/sous-chefs/nodejs/compare/v10.2.3...v11.0.0) (2026-05-19)
### ⚠ BREAKING CHANGES
* migrate nodejs to custom resources ([#306](https://github.com/sous-chefs/nodejs/issues/306))
### Features
* migrate nodejs to custom resources ([#306](https://github.com/sous-chefs/nodejs/issues/306)) ([a941d0f](https://github.com/sous-chefs/nodejs/commit/a941d0f729fad8b386cd8886ad9c232ed41b57e5))
### Bug Fixes
* **ci:** Update workflows to use release pipeline ([#300](https://github.com/sous-chefs/nodejs/issues/300)) ([ef16e2c](https://github.com/sous-chefs/nodejs/commit/ef16e2ce7d32be9d50822926a8d09e30d4a54bad))
## [10.2.3](https://github.com/sous-chefs/nodejs/compare/10.2.2...v10.2.3) (2025-10-15)
### Bug Fixes
* **ci:** Update workflows to use release pipeline ([#300](https://github.com/sous-chefs/nodejs/issues/300)) ([ef16e2c](https://github.com/sous-chefs/nodejs/commit/ef16e2ce7d32be9d50822926a8d09e30d4a54bad))
## 10.2.1 - *2025-06-08*
Standardise files with files in sous-chefs/repo-management
## 10.2.0 - *2024-11-20*
* Add support for new NodeSource repository (Thanks to @stissot)
* Rework source install packages
* Update SUSE packages
## 10.1.22 - *2024-11-19*
* Update default version to current LTS
## 10.1.21 - *2024-11-19*
* Update CI platforms
## 10.1.20 - *2024-11-18*
* Update test matrix check success of the integration stage
## 10.1.19 - *2024-11-18*
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management
## 10.1.16 - *2024-05-03*
Standardise files with files in sous-chefs/repo-management
## 10.1.10 - *2023-04-07*
Standardise files with files in sous-chefs/repo-management
## 10.1.7 - *2023-04-01*
Standardise files with files in sous-chefs/repo-management
## 10.1.6 - *2023-03-20*
Standardise files with files in sous-chefs/repo-management
## 10.1.5 - *2023-03-15*
Standardise files with files in sous-chefs/repo-management
## 10.1.4 - *2023-02-20*
Standardise files with files in sous-chefs/repo-management
## 10.1.2 - *2023-02-14*
Standardise files with files in sous-chefs/repo-management
## 10.1.1 - *2022-12-08*
Standardise files with files in sous-chefs/repo-management
## 10.1.0 - *2022-08-08*
* To ensure consistent environment between `npm install` and `npm list`, pass same environment variables.
## 10.0.1 - *2022-08-07*
* Standardise files with files in sous-chefs/repo-management
* Default to using EL 9 repo for Fedora
* CI: Remove Fedora from source suite
## 10.0.0 - *2022-04-21*
* Update to NodeJS 17.x
* Remove delivery and move to calling RSpec directly via a reusable workflow
* Update tested platforms
* Disable upstream DNF module on EL8 based systems
## 9.0.2 - *2022-02-17*
* Standardise files with files in sous-chefs/repo-management
## 9.0.1 - *2022-02-08*
* Remove delivery folder
## 9.0.0 - *2021-09-13*
* Update the default version to 14 LTS
* Remove testing for EOL platforms
* Add Debian 11 testing
* Fix release version to use for Amazon Linux
## 8.0.0 - *2021-09-02*
* Update metadata and README to Sous Chef
* Enable unified_mode by default and require at least Chef Infra Client 15.3
* Cookstyle fixes
## 7.3.3 - *2021-08-30*
- Standardise files with files in sous-chefs/repo-management
* Standardise files with files in sous-chefs/repo-management
## 7.3.2 - *2021-06-01*
- Standardise files with files in sous-chefs/repo-management
* Standardise files with files in sous-chefs/repo-management
## 7.3.1 - *2020-12-31*
- resolved cookstyle error: attributes/packages.rb:15:55 convention: `Layout/TrailingEmptyLines`
- resolved cookstyle error: test/cookbooks/test/recipes/resource.rb:118:1 convention: `Layout/TrailingEmptyLines`
- Enable builds for opensuse-leap-15
- Add a library method test
* resolved cookstyle error: attributes/packages.rb:15:55 convention: `Layout/TrailingEmptyLines`
* resolved cookstyle error: test/cookbooks/test/recipes/resource.rb:118:1 convention: `Layout/TrailingEmptyLines`
* Enable builds for opensuse-leap-15
* Add a library method test
## 7.3.0 (2020-10-21)
- Add rspec tests for the library methods
- Update the url_invalid? method to return false if it detects an invalid uri
- Add the auto_update option to the npm_package resource. Allows turning off auto_update of npm packages.
- Allow actions and options for OS package installation to be specified as attributes
- Add the live_stream parameter to the npm_package execution to get better installation diagnostics
- Add the auto_update option to the npm_package resource. Allows turning off auto_update of npm packages.
- Update testing
* Add rspec tests for the library methods
* Update the url_invalid? method to return false if it detects an invalid uri
* Add the auto_update option to the npm_package resource. Allows turning off auto_update of npm packages.
* Allow actions and options for OS package installation to be specified as attributes
* Add the live_stream parameter to the npm_package execution to get better installation diagnostics
* Add the auto_update option to the npm_package resource. Allows turning off auto_update of npm packages.
* Update testing
## 7.2.0 (2020-10-07)
- Verify the URI of installed packages to help determine if a good URI has been installed
- Add tests that verify npm-package installed packages
- Get the example test cookbook working
- Add support for installing node on windows
* Verify the URI of installed packages to help determine if a good URI has been installed
* Add tests that verify npm-package installed packages
* Get the example test cookbook working
* Add support for installing node on windows
## 7.1.0 (2020-10-01)
- resolved cookstyle error: recipes/nodejs_from_binary.rb:19:1 refactor: `ChefCorrectness/IncorrectLibraryInjection`
- resolved cookstyle error: recipes/nodejs_from_source.rb:21:1 refactor: `ChefCorrectness/IncorrectLibraryInjection`
- resolved cookstyle error: recipes/npm_from_source.rb:21:1 refactor: `ChefCorrectness/IncorrectLibraryInjection`
- Have ark setup node and npm binaries into PATH
- Add `node_env` to `npm_package` in order to set `NODE_ENV` (useful for some packages)
- Include `npx` as a binary in addition to `npm`, it has been [included since `npm` v5.2.0](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b)
* resolved cookstyle error: recipes/nodejs_from_binary.rb:19:1 refactor: `ChefCorrectness/IncorrectLibraryInjection`
* resolved cookstyle error: recipes/nodejs_from_source.rb:21:1 refactor: `ChefCorrectness/IncorrectLibraryInjection`
* resolved cookstyle error: recipes/npm_from_source.rb:21:1 refactor: `ChefCorrectness/IncorrectLibraryInjection`
* Have ark setup node and npm binaries into PATH
* Add `node_env` to `npm_package` in order to set `NODE_ENV` (useful for some packages)
* Include `npx` as a binary in addition to `npm`, it has been [included since `npm` v5.2.0](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b)
## 7.0.1 (2020-06-04)
- Minor readme fix
* Minor readme fix
## 7.0.0 (2020-06-04)
- Require Chef Infra Client 14+ and remove the build-essential dependency
- Updated the default to Node.js v10.16.3
- Added compatibility with Chef Infra Client 16.2+
- Removed Foodcritic testing
- Updated ChefSpec and Kitchen platforms
- Resolved multiple minor cookstyle issues in the cookbook
- Added a vscode editor config
* Require Chef Infra Client 14+ and remove the build-essential dependency
* Updated the default to Node.js v10.16.3
* Added compatibility with Chef Infra Client 16.2+
* Removed Foodcritic testing
* Updated ChefSpec and Kitchen platforms
* Resolved multiple minor cookstyle issues in the cookbook
* Added a vscode editor config
## 6.0.0 (2018-10-11)
- Use the build_essential resource in the source install recipe instead of the build-essential::default recipe. This way we can use the new built-in build_essential resource in Chef 14+
- Set default version to Node.js v8.12.0
* Use the build_essential resource in the source install recipe instead of the build-essential::default recipe. This way we can use the new built-in build_essential resource in Chef 14+
* Set default version to Node.js v8.12.0
## 5.0.0 (2017-11-15)
- nodejs_npm resource has been converted to a custom resource and renamed to npm_package. The existing resource name will continue to function, but over time code should be updated for the new name. This name change has been made so we can eventually merge this resource into the chef-client.
- compat_resource cookbook dependency has been removed and this cookbook instead requires Chef 12.14 or later
- Chef 13 compatibility has been resolved
- The npm_package resource now properly installs packages when the 'package' property is setA
- Speed up npm operations by only returning a list of the desired package instead of every npm package
- Speed up source installation by using multipackage install for the dependencies
- Remove the broken url_valid? helper which didn't work
* nodejs_npm resource has been converted to a custom resource and renamed to npm_package. The existing resource name will continue to function, but over time code should be updated for the new name. This name change has been made so we can eventually merge this resource into the chef-client.
* compat_resource cookbook dependency has been removed and this cookbook instead requires Chef 12.14 or later
* Chef 13 compatibility has been resolved
* The npm_package resource now properly installs packages when the 'package' property is setA
* Speed up npm operations by only returning a list of the desired package instead of every npm package
* Speed up source installation by using multipackage install for the dependencies
* Remove the broken url_valid? helper which didn't work
## 4.0.0 (2017-07-11)
- Updated the cookbook to require Chef 12.1+ and the compat_resource cookbook
- Removed support for io.js which has merged back into the node.js project
- Removed the dependency on homebrew, yum-epel, and apt cookbooks
- Added node['nodejs']['manage_node'] attribute to use only cookbook's LWRP (required to manage node by nvm)
- Updated the default repository URLs to be the 6.X repos
- Added initial support for Suse and Amazon Linux
- Improved architecture detection to support aarch64
- Improved readme with examples for fetching your own binaries
- Added installation of openssl and xz utilities that are needed for the binary install recipe
- Updated the cookbook license string to be an SPDX compliant string
- Set the minimum version of the ark cookbook to 2.0.2 in order to support Suse
- Updated the default version from 6.9.1 to 6.10.2
- Switched to Delivery local mode for testing
- Added Integration testing in Travis CI with kitchen-dokken and ChefDK
* Updated the cookbook to require Chef 12.1+ and the compat_resource cookbook
* Removed support for io.js which has merged back into the node.js project
* Removed the dependency on homebrew, yum-epel, and apt cookbooks
* Added node['nodejs']['manage_node'] attribute to use only cookbook's LWRP (required to manage node by nvm)
* Updated the default repository URLs to be the 6.X repos
* Added initial support for Suse and Amazon Linux
* Improved architecture detection to support aarch64
* Improved readme with examples for fetching your own binaries
* Added installation of openssl and xz utilities that are needed for the binary install recipe
* Updated the cookbook license string to be an SPDX compliant string
* Set the minimum version of the ark cookbook to 2.0.2 in order to support Suse
* Updated the default version from 6.9.1 to 6.10.2
* Switched to Delivery local mode for testing
* Added Integration testing in Travis CI with kitchen-dokken and ChefDK
## 3.0.0 (2016-11-02)
- Updated the default release to the nodejs 6.9.1\. This requires C++11 extensions to compile, which are only present in GCC 4.8+. Due to this RHEL 5/6 and Ubuntu 12.04 are not supported if using this version.
- Switched the download URLs to the .xz packages since the .tar.gz packages are no longer being created
- Improvements to the readme examples and requirements sections
- Removed installation of apt-transport-https and instead rely on an apt cookbook that will do the same
- Fixed the ChefSpec matchers
- Added Scientific, Oracle, and Amazon as supported distros in the metadata
- Added chef_version metadata
- Removed conflicts and suggests metadata which aren't implemented or recommended for use
- Removed Chef 10 compatibility code
- Switched Integration testing to Inspec from bats
- Added the Apache 2.0 license file to the repo
- Expanded Test Kitchen testing
- Switched from Rubocop to Cookstyle and resolved all warnings
- Switched Travis to testing using ChefDK
* Updated the default release to the nodejs 6.9.1\. This requires C++11 extensions to compile, which are only present in GCC 4.8+. Due to this RHEL 5/6 and Ubuntu 12.04 are not supported if using this version.
* Switched the download URLs to the .xz packages since the .tar.gz packages are no longer being created
* Improvements to the readme examples and requirements sections
* Removed installation of apt-transport-https and instead rely on an apt cookbook that will do the same
* Fixed the ChefSpec matchers
* Added Scientific, Oracle, and Amazon as supported distros in the metadata
* Added chef_version metadata
* Removed conflicts and suggests metadata which aren't implemented or recommended for use
* Removed Chef 10 compatibility code
* Switched Integration testing to Inspec from bats
* Added the Apache 2.0 license file to the repo
* Expanded Test Kitchen testing
* Switched from Rubocop to Cookstyle and resolved all warnings
* Switched Travis to testing using ChefDK
## 2.4.4
- Use HTTPS prefix URLs for node download #98
- Update NPM symlink when installing from source #105
- Add support for NPM private modules #107
* Use HTTPS prefix URLs for node download #98
* Update NPM symlink when installing from source #105
* Add support for NPM private modules #107
## v2.4.2
- Fix check version
- Support iojs package install
* Fix check version
* Support iojs package install
## v2.4.0
- Move `npm_packages` to his own recipe
- Fix different race conditions when using direct recipe call
- Fix npm recipe
* Move `npm_packages` to his own recipe
* Fix different race conditions when using direct recipe call
* Fix npm recipe
## v2.3.2
- Fix package recipe
* Fix package recipe
## v2.3.0
- Support io.js. Use node['nodejs']['engine'].
- Add MacOS support via homebrew
* Support io.js. Use node['nodejs']['engine'].
* Add MacOS support via homebrew
## v2.2.0
- Add node['nodejs']['keyserver']
- Update arm checksum
- Fix `npm_packages` JSON
* Add node['nodejs']['keyserver']
* Update arm checksum
* Fix `npm_packages` JSON
## v2.1.0
- Use official nodesource repository
- Add node['nodejs']['npm_packages'] to install npm package with `default` recipe
* Use official nodesource repository
* Add node['nodejs']['npm_packages'] to install npm package with `default` recipe
## v2.0.0
- Travis integration
- Gems updated
- Rewrite cookbook dependencies
- Added complete test-kitchen integration : Rake, rubocop, foodcritic, vagrant, bats testing ...
- Added NodeJS `install_method` option (sources, bins or packages)
- Added NPM `install_method` option (sources or packages)
- NPM version can now be chosen independently from nodejs' embedded version
- Added a `nodejs_npm` LWRP to manage, install and resolve NPM packages
* Travis integration
* Gems updated
* Rewrite cookbook dependencies
* Added complete test-kitchen integration : Rake, rubocop, foodcritic, vagrant, bats testing ...
* Added NodeJS `install_method` option (sources, bins or packages)
* Added NPM `install_method` option (sources or packages)
* NPM version can now be chosen independently from nodejs' embedded version
* Added a `nodejs_npm` LWRP to manage, install and resolve NPM packages
## v1.3.0
- update default versions to the latest: node - v0.10.15 and npm - v1.3.5
- default to package installation of nodejs on smartos ([@wanelo-pair])
- Add Raspberry pi support ([@robertkowalski])
* update default versions to the latest: node - v0.10.15 and npm - v1.3.5
* default to package installation of nodejs on smartos ([@wanelo-pair])
* Add Raspberry pi support ([@robertkowalski])
## v1.2.0
- implement installation from package on RedHat - ([@vaskas])
* implement installation from package on RedHat - ([@vaskas])
## v1.1.3
- update default version of node to 0.10.13 - and npm - v1.3.4 ([@jodosha][])
* update default version of node to 0.10.13 - and npm - v1.3.4 ([@jodosha][])
## v1.1.2
- update default version of node to 0.10.2 - ([@bakins])
- fully migrated to test-kitchen 1.alpha and vagrant 1.1.x/berkshelf 1.3.1
* update default version of node to 0.10.2 - ([@bakins])
* fully migrated to test-kitchen 1.alpha and vagrant 1.1.x/berkshelf 1.3.1
## v1.1.1
- update default versions to the latest: node - v0.10.0 and npm - v1.2.14
- `make_thread` is now a real attribute - ([@ChrisLundquist])
* update default versions to the latest: node - v0.10.0 and npm - v1.2.14
* `make_thread` is now a real attribute - ([@ChrisLundquist])
## v1.1.0
- rewrite the package install; remove rpm support since there are no longer any packages available anywhere
- add support to install `legacy_packages` from ubuntu repo as well as the latest 0.10.x branch (this is default).
* rewrite the package install; remove rpm support since there are no longer any packages available anywhere
* add support to install `legacy_packages` from ubuntu repo as well as the latest 0.10.x branch (this is default).
## v1.0.4
- add support for binary installation method ([@JulesAU])
* add support for binary installation method ([@JulesAU])
## v1.0.3
- 7.3.1 - *2020-12-31*
* 7.3.1 - *2020-12-31*
## v1.0.2
- add smartos support for package install ([@sax])
- support to compile with all processors available (default 2 if unknown) - ([@ChrisLundquist])
- moved to `platform_family` syntax
- ensure npm recipe honours the 'source' or 'package' setting - ([@markbirbeck])
- updated the default versions to the latest stable node/npm
* add smartos support for package install ([@sax])
* support to compile with all processors available (default 2 if unknown) - ([@ChrisLundquist])
* moved to `platform_family` syntax
* ensure npm recipe honours the 'source' or 'package' setting - ([@markbirbeck])
* updated the default versions to the latest stable node/npm
## v1.0.1
- fixed bug that prevented overwritting the node/npm versions (moved the `src_url`s as local variables instead of attributes) - ([@johannesbecker])
- updated the default versions to the latest node/npm
* fixed bug that prevented overwritting the node/npm versions (moved the `src_url`s as local variables instead of attributes) - ([@johannesbecker])
* updated the default versions to the latest node/npm
## v1.0.0
- added packages installation support ([@smith])
* added packages installation support ([@smith])
[@bakins]: https://github.com/bakins
[@chrislundquist]: https://github.com/ChrisLundquist
[@gmccue]: https://github.com/gmccue
[@johannesbecker]: https://github.com/johannesbecker
[@julesau]: https://github.com/JulesAU
[@markbirbeck]: https://github.com/markbirbeck
[@predominant]: https://github.com/predominant
[@robertkowalski]: https://github.com/robertkowalski
[@sax]: https://github.com/sax
[@sjlu]: https://github.com/sjlu
[@smith]: https://github.com/smith
[@vaskas]: https://github.com/vaskas
[@wanelo-pair]: https://github.com/wanelo-pair
[@bakins]: <https://github.com/bakins>
[@chrislundquist]: <https://github.com/ChrisLundquist>
[@johannesbecker]: <https://github.com/johannesbecker>
[@julesau]: <https://github.com/JulesAU>
[@markbirbeck]: <https://github.com/markbirbeck>
[@robertkowalski]: <https://github.com/robertkowalski>
[@sax]: <https://github.com/sax>
[@smith]: <https://github.com/smith>
[@vaskas]: <https://github.com/vaskas>
[@wanelo-pair]: <https://github.com/wanelo-pair>
+69
View File
@@ -0,0 +1,69 @@
# Limitations
This cookbook defaults to Node.js 24 LTS, using Node.js v24.15.0 checksums from the official `SHASUMS256.txt` published for `latest-v24.x` on 2026-04-16.
Sources checked on 2026-04-29:
* Node.js release schedule: <https://github.com/nodejs/Release/blob/main/schedule.json>
* Node.js latest v24 artifacts: <https://nodejs.org/dist/latest-v24.x/>
* Node.js v24 checksums: <https://nodejs.org/dist/latest-v24.x/SHASUMS256.txt>
* NodeSource distributions page: <https://nodesource.com/products/distributions>
* NodeSource distributions repository: <https://github.com/nodesource/distributions>
## Package Availability
### APT (Debian/Ubuntu)
NodeSource documents Node 24 packages for:
* Ubuntu 20.04, 22.04, 24.04: `amd64`, `armhf`, `arm64`
* Debian 10, 11, 12: `amd64`, `armhf`, `arm64`
The cookbook only declares currently supported, non-EOL Debian/Ubuntu platforms in `metadata.rb`: Debian 12 or later and Ubuntu 22.04 or later. NodeSource packages use the `nodistro` repository distribution.
### DNF/YUM (RHEL family)
NodeSource documents RPM packages for RHEL 8/9, Fedora 29+, and Amazon Linux 2023 on `x86_64` and `arm64`. The repository URL pattern used by this cookbook is:
```text
<https://rpm.nodesource.com/pub_<major>>.x/nodistro/nodejs/$basearch
```
The cookbook declares AlmaLinux, Amazon Linux 2023, CentOS Stream, Fedora, Oracle Linux, Red Hat, and Rocky Linux where current test images are available.
### Zypper (SUSE)
NodeSource does not publish SUSE repository rows in the current distributions documentation. This migration does not declare SUSE/openSUSE support in `metadata.rb`.
### Windows and macOS
Windows support is limited to `nodejs_install` with `install_method 'chocolatey'`. macOS support is limited to package installation through the platform package provider where available. Dokken coverage is Linux-only.
## Architecture Limitations
Official Node.js v24.15.0 source and binary checksums pinned by this cookbook:
| Artifact | SHA256 |
| ---------------------------------- | ------------------------------------------------------------------ |
| `node-v24.15.0.tar.gz` | `729de494dd2872e5a3a6c32a1cd156a5413d4aca2772b2d873ee86bb5531bcd9` |
| `node-v24.15.0-linux-x64.tar.gz` | `44836872d9aec49f1e6b52a9a922872db9a2b02d235a616a5681b6a85fec8d89` |
| `node-v24.15.0-linux-arm64.tar.gz` | `73afc234d558c24919875f51c2d1ea002a2ada4ea6f83601a383869fefa64eed` |
The `nodejs_install` binary action currently models Linux `x64` and `arm64` checksums. Other official Node.js artifacts can be installed by passing `binary_url` and the matching checksum.
## Source/Compiled Installation
### Build Dependencies
| Platform Family | Packages |
| ------------------ | ---------------------------------------------------- |
| Debian | `build-essential`, `libssl-dev`, `python3` |
| RHEL/Fedora/Amazon | `build-essential`, `openssl-devel`, `python3`, `tar` |
| Other | `build-essential`, `python3` |
Source builds are much slower than package or binary installs and are not used as the default Kitchen smoke path.
## Known Issues
* Node.js 20 reaches end-of-life on 2026-04-30, so this migration does not keep old Node 20 defaults.
* NodeSource repository docs currently show some LTS/current labels that lag the official Node.js release schedule. The cookbook version defaults follow the official Node.js release schedule and official Node.js checksum artifacts.
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
name 'nodejs'
default_source :supermarket
run_list 'recipe[test::default]'
cookbook 'nodejs', path: '.'
cookbook 'test', path: './test/cookbooks/test'
Dir.children('./test/cookbooks/test/recipes').grep(/\.rb\z/).sort.each do |recipe|
recipe_name = File.basename(recipe, '.rb')
named_run_list recipe_name.to_sym, "recipe[test::#{recipe_name}]"
end
+63 -174
View File
@@ -1,220 +1,109 @@
# [nodejs-cookbook](https://github.com/redguide/nodejs)
[![CK Version](http://img.shields.io/cookbook/v/nodejs.svg?branch=master)](https://supermarket.chef.io/cookbooks/nodejs) [![Build Status](https://img.shields.io/travis/redguide/nodejs.svg)](https://travis-ci.org/redguide/nodejs)
[![Cookbook Version](https://img.shields.io/cookbook/v/nodejs.svg)](https://supermarket.chef.io/cookbooks/nodejs)
[![CI State](https://github.com/sous-chefs/nodejs/workflows/ci/badge.svg)](https://github.com/sous-chefs/nodejs/actions?query=workflow%3Aci)
[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers)
[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
Installs node.js/npm and includes a resource for managing npm packages
Provides custom resources for installing Node.js/npm and managing npm packages.
## Maintainers
This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If youd like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF).
## Requirements
### Platforms
- Debian/Ubuntu
- RHEL/CentOS/Scientific/Amazon/Oracle
- openSUSE
- Windows
Note: Source installs require GCC 4.8+, which is not included on older distro releases
* Debian/Ubuntu
* RHEL family/Fedora/Amazon Linux
* macOS where platform packages are available
* Windows through Chocolatey
### Chef
- Chef Infra Client 14+
* Chef Infra Client 15.3+
### Cookbooks
- ark
* ark
* chocolatey
## Usage
Include the nodejs recipe to install node on your system based on the default installation method:
Install Node.js with the default platform method:
```ruby
include_recipe "nodejs"
nodejs_install 'nodejs'
```
### Install methods
#### Package
Install node from packages:
```ruby
node['nodejs']['install_method'] = 'package' # Not necessary because it's the default
include_recipe "nodejs"
# Or
include_recipe "nodejs::nodejs_from_package"
nodejs_install 'nodejs' do
install_method 'package'
version '24.15.0'
```
By default this will setup deb/rpm repositories from nodesource.com, which include up to date NodeJS packages. If you prefer to use distro provided package you can disable this behavior by setting `node['nodejs']['install_repo']` to `false`.
#### Binary
Install node from official prebuilt binaries:
Install Node.js from official prebuilt binaries:
```ruby
node['nodejs']['install_method'] = 'binary'
include_recipe "nodejs"
# Or
include_recipe "nodejs::nodejs_from_binary"
# Or set a specific version of nodejs to be installed
node.default['nodejs']['install_method'] = 'binary'
node.default['nodejs']['version'] = '5.9.0'
node.default['nodejs']['binary']['checksum'] = '99c4136cf61761fac5ac57f80544140a3793b63e00a65d4a0e528c9db328bf40'
# Or fetch the binary from your own location
node.default['nodejs']['install_method'] = 'binary'
node.default['nodejs']['binary']['url'] = 'https://s3.amazonaws.com/my-bucket/node-v7.8.0-linux-x64.tar.gz'
node.default['nodejs']['binary']['checksum'] = '0bd86f2a39221b532172c7d1acb57f0b0cba88c7b82ea74ba9d1208b9f6f9697'
nodejs_install 'nodejs' do
install_method 'binary'
```
#### Source
Install node from sources:
Install Node.js from source:
```ruby
node['nodejs']['install_method'] = 'source'
include_recipe "nodejs"
# Or
include_recipe "nodejs::nodejs_from_source"
nodejs_install 'nodejs' do
install_method 'source'
end
```
#### Chocolatey
Install node from chocolatey:
```chef
node['nodejs']['install_method'] = 'chocolatey'
include_recipe "nodejs"
# Or
include_recipe "nodejs::nodejs_from_chocolatey"
```
## NPM
Npm is included in nodejs installs by default. By default, we are using it and call it `embedded`. Adding recipe `nodejs::npm` assure you to have npm installed and let you choose install method with `node['nodejs']['npm']['install_method']`
```ruby
include_recipe "nodejs::npm"
```
_Warning:_ This recipe will include the `nodejs` recipe, which by default includes `nodejs::nodejs_from_package` if you did not set `node['nodejs']['install_method']`.
## Resources
### npm_package
note: This resource was previously named nodejs_npm. Calls to that resource name will still function, but cookbooks should be updated for the new npm_package resource name.
`npm_package` lets you install npm packages from various sources:
- npm registry:
- name: `property :package`
- version: `property :version` (optional)
- url: `property :url`
- for git use `git://{your_repo}`
- from a json (package.json by default): `property :json`
- use `true` for default
- use a `String` to specify json file
Packages can be installed globally (by default) or in a directory (by using `attribute :path`)
You can specify an `NPM_TOKEN` environment variable for accessing [NPM private modules](https://docs.npmjs.com/private-modules/intro) by using `attribute :npm_token`
You can specify a `NODE_ENV` environment variable, in the case that some element of your installation depends on this by using `attribute :node_env`. E.g., using [`node-config`](https://www.npmjs.com/package/config) as part of your postinstall script. Please note that adding the `--production` option will override this to `NODE_ENV=production`.
You can append more specific options to npm command with `attribute :options` array :
You can specify auto_update as false to stop the npm install command from running and updating an installed package. Running the command will update packages within restrictions imposed by a package.json file. The default behavior is to update automatically.
- use an array of options (w/ dash), they will be added to npm call.
- ex: `['--production','--force']` or `['--force-latest']`
You can specify live_stream true for the resource to have the package install information included in the chef-client log outout for better npm package diagnostics and trouble shooting.
This LWRP attempts to use vanilla npm as much as possible (no custom wrapper).
### Packages
Install npm packages:
```ruby
npm_package 'express'
npm_package 'async' do
version '0.6.2'
end
npm_package 'request' do
url 'github mikeal/request'
end
npm_package 'grunt' do
path '/home/random/grunt'
json true
user 'random'
node_env 'staging'
end
npm_package 'my_private_module' do
path '/home/random/myproject' # The root path to your project, containing a package.json file
json true
npm_token '12345-abcde-e5d4c3b2a1'
user 'random'
options ['--production'] # Only install dependencies. Skip devDependencies
end
```
[Working Examples](test/cookbooks/nodejs_test/recipes/npm.rb)
Or add packages via attributes (which accept the same attributes as the LWRP above):
```json
"nodejs": {
"npm_packages": [
{
"name": "express"
},
{
"name": "async",
"version": "0.6.2"
},
{
"name": "request",
"url": "github mikeal/request"
}
{
"name": "grunt",
"path": "/home/random/grunt",
"json": true,
"user": "random"
}
nodejs_npm_packages 'application packages' do
packages [
{ name: 'socket.io', version: '4.8.1' },
]
}
end
```
## License & Authors
See [migration.md](migration.md) for the breaking recipe/attribute migration guide.
**Author:** Marius Ducea (marius@promethost.com)
**Author:** Nathan L Smith (nlloyds@gmail.com)
**Author:** Guilhem Lettron (guilhem@lettron.fr)
**Author:** Barthelemy Vessemont (bvessemont@gmail.com)
## Resources
**Copyright:** Chef Software, Inc.
* [nodejs_install](documentation/nodejs_install.md)
* [nodejs_repository](documentation/nodejs_repository.md)
* [nodejs_npm_install](documentation/nodejs_npm_install.md)
* [nodejs_npm_packages](documentation/nodejs_npm_packages.md)
* [npm_package](documentation/nodejs_npm_package.md)
```
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
## Contributors
http://www.apache.org/licenses/LICENSE-2.0
This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
### Backers
Thank you to all our backers!
![<https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40>)
### Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
![<https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100>)
![<https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100>)
![<https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100>)
![<https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100>)
![<https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100>)
![<https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100>)
![<https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100>)
![<https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100>)
![<https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100>)
![<https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100>)
-44
View File
@@ -1,44 +0,0 @@
#
# Cookbook:: nodejs
# Attributes:: nodejs
#
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
case node['platform_family']
when 'smartos', 'rhel', 'debian', 'fedora', 'mac_os_x', 'suse', 'amazon'
default['nodejs']['install_method'] = 'package'
when 'windows'
default['nodejs']['install_method'] = 'chocolatey'
else
default['nodejs']['install_method'] = 'source'
end
default['nodejs']['version'] = '10.16.3'
default['nodejs']['prefix_url']['node'] = 'https://nodejs.org/dist/'
default['nodejs']['tmpdir'] = '/tmp'
default['nodejs']['source']['url'] = nil # Auto generated
default['nodejs']['source']['checksum'] = 'db5a5e03a815b84a1266a4b48bb6a6d887175705f84fd2472f0d28e5e305a1f8'
default['nodejs']['binary']['url'] = nil # Auto generated
default['nodejs']['binary']['checksum']['linux_x64'] = '2f0397bb81c1d0c9901b9aff82a933257bf60f3992227b86107111a75b9030d9'
default['nodejs']['binary']['checksum']['linux_arm64'] = '3bab16e7107092e43426e082ee9fd88ef0a43a35816f662f14563bcc5152600d'
default['nodejs']['binary']['append_env_path'] = true
default['nodejs']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2
default['nodejs']['manage_node'] = true
-2
View File
@@ -1,2 +0,0 @@
default['nodejs']['npm']['install_method'] = 'embedded'
default['nodejs']['npm']['version'] = 'latest'
-15
View File
@@ -1,15 +0,0 @@
include_attribute 'nodejs::default'
include_attribute 'nodejs::repo'
default['nodejs']['packages'] = value_for_platform_family(
'debian' => node['nodejs']['install_repo'] ? ['nodejs'] : %w(nodejs npm nodejs-dev),
%w(rhel fedora amazon) => node['nodejs']['install_repo'] ? %w(nodejs nodejs-devel) : %w(nodejs npm nodejs-dev),
'suse' => node['platform_version'].to_i < 42 ? %w(nodejs10 npm10 nodejs10-devel) : %w(nodejs4 npm4 nodejs4-devel),
'mac_os_x' => ['node'],
'freebsd' => %w(node npm),
'default' => ['nodejs']
)
# Add options and actions by package name
default['nodejs']['package_action'] = { default: :install }
default['nodejs']['package_options'] = { default: '' }
-12
View File
@@ -1,12 +0,0 @@
case node['platform_family']
when 'debian'
default['nodejs']['install_repo'] = true
default['nodejs']['repo'] = 'https://deb.nodesource.com/node_10.x'
default['nodejs']['keyserver'] = 'keyserver.ubuntu.com'
default['nodejs']['key'] = '1655a0ab68576280'
when 'rhel', 'fedora', 'amazon'
default['nodejs']['install_repo'] = true
release_ver = platform?('amazon') ? 6 : node['platform_version'].to_i
default['nodejs']['repo'] = "https://rpm.nodesource.com/pub_10.x/el/#{release_ver}/$basearch"
default['nodejs']['key'] = 'https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL'
end
+3 -6
View File
@@ -61,7 +61,7 @@ Dangerfile
examples/*
features/*
Guardfile
kitchen.yml*
kitchen*.yml
mlc_config.json
Procfile
Rakefile
@@ -83,10 +83,8 @@ test/*
*/.hg/*
*/.svn/*
# Berkshelf #
#############
Berksfile
Berksfile.lock
# Dependency cache #
####################
cookbooks/*
tmp
@@ -98,7 +96,6 @@ Gemfile.lock
# Policyfile #
##############
Policyfile.rb
Policyfile.lock.json
# Documentation #
-88
View File
@@ -1,88 +0,0 @@
---
driver:
name: dokken
privileged: true # because Docker and SystemD
chef_version: <%= ENV['CHEF_VERSION'] || 'current' %>
chef_license: accept-no-persist
transport:
name: dokken
provisioner:
name: dokken
deprecations_as_errors: true
verifier:
name: inspec
platforms:
- name: amazonlinux
driver:
image: dokken/amazonlinux
pid_one_command: /sbin/init
- name: amazonlinux-2
driver:
image: dokken/amazonlinux-2
pid_one_command: /usr/lib/systemd/systemd
- name: debian-8
driver:
image: dokken/debian-8
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- name: debian-9
driver:
image: dokken/debian-9
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- name: debian-10
driver:
image: dokken/debian-10
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- name: centos-7
driver:
image: dokken/centos-7
pid_one_command: /usr/lib/systemd/systemd
- name: centos-8
driver:
image: dokken/centos-8
pid_one_command: /usr/lib/systemd/systemd
- name: fedora-latest
driver:
image: dokken/fedora-latest
pid_one_command: /usr/lib/systemd/systemd
- name: opensuse-leap-15
driver:
image: dokken/opensuse-leap-15
pid_one_command: /bin/systemd
- name: ubuntu-18.04
driver:
image: dokken/ubuntu-18.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- name: ubuntu-20.04
driver:
image: dokken/ubuntu-20.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install python -y
- name: opensuse-leap-15
driver:
image: dokken/opensuse-leap-15
pid_one_command: /bin/systemd
+88 -13
View File
@@ -1,19 +1,96 @@
# frozen_string_literal: true
module NodeJs
module Helper
def npm_dist
if node['nodejs']['npm']['url']
{ 'url' => node['nodejs']['npm']['url'] }
def default_install_method
case node['platform_family']
when 'debian', 'rhel', 'fedora', 'amazon', 'mac_os_x', 'suse'
'package'
when 'windows'
'chocolatey'
else
require 'open-uri'
require 'json'
result = JSON.parse(URI.parse("https://registry.npmjs.org/npm/#{node['nodejs']['npm']['version']}").read, max_nesting: false)
ret = { 'url' => result['dist']['tarball'], 'version' => result['_npmVersion'], 'shasum' => result['dist']['shasum'] }
Chef::Log.debug("Npm dist #{ret}")
ret
'source'
end
end
def default_packages(install_repository)
case node['platform_family']
when 'debian'
install_repository ? ['nodejs'] : %w(nodejs npm nodejs-dev)
when 'rhel', 'fedora', 'amazon'
install_repository ? %w(nodejs nodejs-devel) : %w(nodejs npm nodejs-devel)
when 'suse'
%w(nodejs npm nodejs-devel)
when 'mac_os_x'
['node']
else
['nodejs']
end
end
def default_build_packages
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
%w(openssl-devel python3 tar)
when 'debian'
%w(libssl-dev python3)
else
%w(python3)
end
end
def dnf_python_package?(package_name)
package_name == 'python3' && platform_family?('rhel', 'fedora', 'amazon')
end
def default_make_threads
node['cpu'] ? node['cpu']['total'].to_i : 2
end
def node_major_from_version(version)
version.to_s.split('.').first
end
def nodejs_arch
machine = node['kernel']['machine']
case machine
when /armv6l/
'arm-pi'
when /aarch64/
'arm64'
when /x86_64/
'x64'
when /\d86/
'x86'
else
machine
end
end
def nodejs_binary_checksum(checksums)
checksums["linux_#{nodejs_arch}"]
end
def nodejs_source_url(version, prefix_url, source_url)
source_url || ::URI.join(prefix_url, "v#{version}/", "node-v#{version}.tar.gz").to_s
end
def nodejs_binary_url(version, prefix_url, binary_url)
binary_url || ::URI.join(prefix_url, "v#{version}/", "node-v#{version}-linux-#{nodejs_arch}.tar.gz").to_s
end
def npm_dist(version, url = nil)
return { 'url' => url } if url
require 'open-uri'
require 'json'
result = JSON.parse(URI.parse("https://registry.npmjs.org/npm/#{version}").read, max_nesting: false)
ret = { 'url' => result['dist']['tarball'], 'version' => result['_npmVersion'], 'shasum' => result['dist']['shasum'] }
Chef::Log.debug("Npm dist #{ret}")
ret
end
def npm_list(package, path = nil, environment = {})
require 'json'
cmd = if path
@@ -47,9 +124,7 @@ module NodeJs
(version ? list[package]['version'] == version : true)
end
def npm_package_installed?(package, version = nil, path = nil, npm_token = nil)
environment = { 'NPM_TOKEN' => npm_token } if npm_token
def npm_package_installed?(package, version = nil, path = nil, environment = {})
list = npm_list(package, path, environment)['dependencies']
# Return true if package installed and installed to good version
# see if we really want to add the url check
+18 -18
View File
@@ -1,27 +1,27 @@
{
"name": "nodejs",
"description": "Installs/Configures node.js",
"description": "Provides resources for installing Node.js and managing npm packages",
"long_description": "",
"maintainer": "redguide",
"maintainer_email": "guilhem@lettron.fr",
"maintainer": "Sous Chefs",
"maintainer_email": "help@sous-chefs.org",
"license": "Apache-2.0",
"platforms": {
"debian": ">= 0.0.0",
"ubuntu": ">= 0.0.0",
"centos": ">= 0.0.0",
"redhat": ">= 0.0.0",
"scientific": ">= 0.0.0",
"oracle": ">= 0.0.0",
"amazon": ">= 0.0.0",
"smartos": ">= 0.0.0",
"almalinux": ">= 8.0",
"amazon": ">= 2023.0",
"centos_stream": ">= 9.0",
"debian": ">= 12.0",
"fedora": ">= 0.0.0",
"mac_os_x": ">= 0.0.0",
"opensuseleap": ">= 0.0.0",
"suse": ">= 0.0.0",
"oracle": ">= 8.0",
"redhat": ">= 8.0",
"rocky": ">= 8.0",
"ubuntu": ">= 22.04",
"windows": ">= 0.0.0"
},
"dependencies": {
"ark": ">= 2.0.2",
"chocolatey": ">= 3.0"
"chocolatey": ">= 3.0",
"yum": ">= 7.2"
},
"providing": {
@@ -29,13 +29,13 @@
"recipes": {
},
"version": "7.3.3",
"source_url": "https://github.com/redguide/nodejs",
"issues_url": "https://github.com/redguide/nodejs/issues",
"version": "11.0.1",
"source_url": "https://github.com/sous-chefs/nodejs",
"issues_url": "https://github.com/sous-chefs/nodejs/issues",
"privacy": false,
"chef_versions": [
[
">= 14"
">= 15.3"
]
],
"ohai_versions": [
+24 -13
View File
@@ -1,16 +1,27 @@
name 'nodejs'
maintainer 'redguide'
maintainer_email 'guilhem@lettron.fr'
license 'Apache-2.0'
description 'Installs/Configures node.js'
source_url 'https://github.com/redguide/nodejs'
issues_url 'https://github.com/redguide/nodejs/issues'
chef_version '>= 14'
version '7.3.3'
# frozen_string_literal: true
name 'nodejs'
maintainer 'Sous Chefs'
maintainer_email 'help@sous-chefs.org'
license 'Apache-2.0'
description 'Provides resources for installing Node.js and managing npm packages'
version '11.0.1'
source_url 'https://github.com/sous-chefs/nodejs'
issues_url 'https://github.com/sous-chefs/nodejs/issues'
chef_version '>= 15.3'
supports 'almalinux', '>= 8.0'
supports 'amazon', '>= 2023.0'
supports 'centos_stream', '>= 9.0'
supports 'debian', '>= 12.0'
supports 'fedora'
supports 'mac_os_x'
supports 'oracle', '>= 8.0'
supports 'redhat', '>= 8.0'
supports 'rocky', '>= 8.0'
supports 'ubuntu', '>= 22.04'
supports 'windows'
depends 'ark', '>= 2.0.2'
depends 'chocolatey', '>= 3.0'
%w(debian ubuntu centos redhat scientific oracle amazon smartos mac_os_x opensuseleap suse windows).each do |os|
supports os
end
depends 'yum', '>= 7.2'
+52
View File
@@ -0,0 +1,52 @@
# Migration Guide
This release is a breaking migration from recipes and node attributes to custom resources.
## What Changed
The cookbook no longer exposes `nodejs::default`, `nodejs::install`, `nodejs::repo`, `nodejs::npm`, `nodejs::npm_packages`, or the install-method recipes. The `attributes/` directory was removed. Configure Node.js through resource properties instead of `node['nodejs']` attributes.
## Recipe to Resource Mapping
| Before | After |
| ------------------------------------------------- | ------------------------------------------------------------- |
| `include_recipe 'nodejs::default'` | `nodejs_install 'nodejs'` plus optional `nodejs_npm_packages` |
| `include_recipe 'nodejs::repo'` | `nodejs_repository 'nodesource'` |
| `include_recipe 'nodejs::nodejs_from_package'` | `nodejs_install 'nodejs' do install_method 'package' end` |
| `include_recipe 'nodejs::nodejs_from_binary'` | `nodejs_install 'nodejs' do install_method 'binary' end` |
| `include_recipe 'nodejs::nodejs_from_source'` | `nodejs_install 'nodejs' do install_method 'source' end` |
| `include_recipe 'nodejs::nodejs_from_chocolatey'` | `nodejs_install 'nodejs' do install_method 'chocolatey' end` |
| `include_recipe 'nodejs::npm'` | `nodejs_npm_install 'npm'` |
| `node['nodejs']['npm_packages']` | `nodejs_npm_packages 'packages'` |
## Examples
Install Node.js from NodeSource packages:
```ruby
nodejs_install 'nodejs' do
install_method 'package'
version '24.15.0'
end
```
Install packages that used to be configured with `node['nodejs']['npm_packages']`:
```ruby
nodejs_npm_packages 'application packages' do
packages [
{ name: 'express' },
{ name: 'socket.io', version: '4.8.1' },
]
end
```
The `nodejs_npm` alias still works for the `npm_package` resource, but it no longer auto-includes any Node.js or npm recipes. Install Node.js first:
```ruby
nodejs_install 'nodejs'
nodejs_npm 'express'
```
See `test/cookbooks/test/recipes/` for runnable migration examples used by Kitchen.
-23
View File
@@ -1,23 +0,0 @@
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook:: nodejs
# Recipe:: default
#
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe 'nodejs::install' if node['nodejs']['manage_node']
include_recipe 'nodejs::npm' if node['nodejs']['manage_node']
include_recipe 'nodejs::npm_packages' if node['nodejs']['manage_node']
-21
View File
@@ -1,21 +0,0 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook:: nodejs
# Recipe:: install
#
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe "nodejs::nodejs_from_#{node['nodejs']['install_method']}"
-1
View File
@@ -1 +0,0 @@
Chef::Log.fatal('The nodejs::iojs recipe has been deprecated. If you need iojs installation pin to cookbook version 3.0.1.')
-21
View File
@@ -1,21 +0,0 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook:: nodejs
# Recipe:: nodejs
#
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Chef::Log.fatal('The nodejs::nodejs recipe is no longer used. Use nodejs::install to install nodejs instead.')
@@ -1,67 +0,0 @@
#
# Author:: Julian Wilde (jules@jules.com.au)
# Cookbook:: nodejs
# Recipe:: install_from_binary
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Chef::DSL::Recipe.include NodeJs::Helper
# Shamelessly borrowed from http://docs.chef.io/dsl_recipe_method_platform.html
# Surely there's a more canonical way to get arch?
arch = if node['kernel']['machine'] =~ /armv6l/
# FIXME: This should really check the version of node we're looking for
# as it seems that they haven't build an `arm-pi` version in a while...
# if it's old, return this, otherwise just return `node['kernel']['machine']`
'arm-pi' # assume a raspberry pi
elsif node['kernel']['machine'] =~ /aarch64/
'arm64'
elsif node['kernel']['machine'] =~ /x86_64/
'x64'
elsif node['kernel']['machine'] =~ /\d86/
'x86'
else
node['kernel']['machine']
end
# needed to uncompress the binary
package 'tar' if platform_family?('rhel', 'fedora', 'amazon', 'suse')
# package_stub is for example: "node-v6.9.1-linux-x64.tar.gz"
version = "v#{node['nodejs']['version']}/"
prefix = node['nodejs']['prefix_url']['node']
filename = "node-v#{node['nodejs']['version']}-linux-#{arch}.tar.gz"
archive_name = 'nodejs-binary'
binaries = ['bin/node']
binaries.push('bin/npm') if node['nodejs']['npm']['install_method'] == 'embedded'
binaries.push('bin/npx') if node['nodejs']['npm']['install_method'] == 'embedded'
if node['nodejs']['binary']['url']
nodejs_bin_url = node['nodejs']['binary']['url']
checksum = node['nodejs']['binary']['checksum']
else
nodejs_bin_url = ::URI.join(prefix, version, filename).to_s
checksum = node['nodejs']['binary']['checksum']["linux_#{arch}"]
end
ark archive_name do
url nodejs_bin_url
version node['nodejs']['version']
checksum checksum
has_binaries binaries
append_env_path node['nodejs']['binary']['append_env_path']
action :install
end
@@ -1,24 +0,0 @@
#
# Author:: Hossein Margani (hossein@margani.dev)
# Cookbook:: nodejs
# Recipe:: install_from_chocolatey
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe 'chocolatey'
chocolatey_package 'nodejs-lts' do
version node['nodejs']['version'] if node['nodejs']['version']
action :upgrade
end
@@ -1,36 +0,0 @@
#
# Author:: Nathan L Smith (nlloyds@gmail.com)
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook:: nodejs
# Recipe:: package
#
# Copyright:: 2012-2017, Cramer Development, Inc.
# Copyright:: 2013-2017, Opscale
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe 'nodejs::repo' if node['nodejs']['install_repo']
unless node['nodejs']['packages']
Chef::Log.error 'No package for nodejs'
Chef::Log.warn 'Please use the source or binary method to install node'
return
end
node['nodejs']['packages'].each do |node_pkg|
package node_pkg do
action node['nodejs']['package_action'][node_pkg] if node['nodejs']['package_action'][node_pkg]
options node['nodejs']['package_options'][node_pkg] if node['nodejs']['package_options'][node_pkg]
end
end
@@ -1,49 +0,0 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook:: nodejs
# Recipe:: source
#
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Chef::DSL::Recipe.include NodeJs::Helper
build_essential 'install build tools'
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
# The ark resource uses and requires python2 for builds
package %w(openssl-devel python2 tar)
when 'debian'
package %w(libssl-dev python)
when 'suse'
package %w(python)
end
version = "v#{node['nodejs']['version']}/"
prefix = node['nodejs']['prefix_url']['node']
filename = "node-v#{node['nodejs']['version']}.tar.gz"
archive_name = 'nodejs-source'
nodejs_src_url = node['nodejs']['source']['url'] || ::URI.join(prefix, version, filename).to_s
ark archive_name do
url nodejs_src_url
version node['nodejs']['version']
checksum node['nodejs']['source']['checksum']
make_opts ["-j #{node['nodejs']['make_threads']}"]
action :install_with_make
environment(PYTHON: 'python2')
end
-28
View File
@@ -1,28 +0,0 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook:: nodejs
# Recipe:: npm
#
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
case node['nodejs']['npm']['install_method']
when 'embedded'
include_recipe 'nodejs::install'
when 'source'
include_recipe 'nodejs::npm_from_source'
else
Chef::Log.error('No install method found for npm')
end
@@ -1,32 +0,0 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook:: nodejs
# Recipe:: npm
#
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Chef::DSL::Recipe.include NodeJs::Helper
include_recipe 'nodejs::nodejs_from_source'
dist = npm_dist
ark 'npm' do
url dist['url']
checksum dist['checksum']
version dist['version']
action :install_with_make
end
-13
View File
@@ -1,13 +0,0 @@
if node['nodejs'].key?('npm_packages')
node['nodejs']['npm_packages'].each do |pkg|
pkg_action = pkg.key?('action') ? pkg['action'] : :install
f = npm_package "nodejs_npm-#{pkg['name']}-#{pkg_action}" do
action :nothing
package pkg['name']
end
pkg.each do |key, value|
f.send(key, value) unless key == 'name' || key == 'action'
end
f.action(pkg_action)
end
end
-19
View File
@@ -1,19 +0,0 @@
case node['platform_family']
when 'debian'
package 'nodejs-apt-transport-https' do
package_name 'apt-transport-https'
end
apt_repository 'node.js' do
uri node['nodejs']['repo']
components ['main']
keyserver node['nodejs']['keyserver']
key node['nodejs']['key']
end
when 'rhel', 'fedora', 'amazon'
yum_repository 'node.js' do
description 'nodesource.com nodejs repository'
baseurl node['nodejs']['repo']
gpgkey node['nodejs']['key']
end
end
@@ -0,0 +1,12 @@
{
"packages": {
".": {
"package-name": "nodejs",
"changelog-path": "CHANGELOG.md",
"release-type": "ruby",
"include-component-in-tag": false,
"version-file": "metadata.rb"
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
+18
View File
@@ -0,0 +1,18 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"packageRules": [
{
"groupName": "Actions",
"matchUpdateTypes": ["minor", "patch", "pin"],
"automerge": true,
"addLabels": ["Release: Patch", "Skip: Announcements"]
},
{
"groupName": "Actions",
"matchUpdateTypes": ["major"],
"automerge": false,
"addLabels": ["Release: Patch", "Skip: Announcements"]
}
]
}
@@ -0,0 +1,2 @@
property :version, String, default: '24.15.0'
property :prefix_url, String, default: 'https://nodejs.org/dist/'
@@ -0,0 +1,146 @@
# frozen_string_literal: true
provides :nodejs_install
unified_mode true
use '_partial/_nodejs'
property :install_method, String, equal_to: %w(package binary source chocolatey)
property :install_repository, [true, false], default: true
property :packages, [Array, nil], default: nil
property :package_action, [Symbol, String], default: :install
property :package_options, [String, nil]
property :disable_dnf_module, [true, false], default: true
property :source_url, [String, nil]
property :source_checksum, [String, nil], default: '729de494dd2872e5a3a6c32a1cd156a5413d4aca2772b2d873ee86bb5531bcd9'
property :binary_url, [String, nil]
property :binary_checksums, Hash,
default: {
'linux_x64' => '44836872d9aec49f1e6b52a9a922872db9a2b02d235a616a5681b6a85fec8d89',
'linux_arm64' => '73afc234d558c24919875f51c2d1ea002a2ada4ea6f83601a383869fefa64eed',
}
property :append_env_path, [true, false], default: true
property :make_threads, [Integer, String, nil], default: nil
property :build_packages, [Array, nil], default: nil
property :chocolatey_package_name, String, default: 'nodejs-lts'
default_action :install
action :install do
case requested_install_method
when 'package'
nodejs_repository 'nodesource' do
node_major node_major_from_version(new_resource.version)
action :create
only_if { new_resource.install_repository }
end
dnf_module 'nodejs' do
action :disable
only_if { disable_dnf_module? }
end
resolved_packages.each do |pkg|
package pkg do
action new_resource.package_action.to_sym
options new_resource.package_options if new_resource.package_options
end
end
when 'binary'
package 'tar' if platform_family?('rhel', 'fedora', 'amazon', 'suse')
ark 'nodejs-binary' do
url nodejs_binary_url(new_resource.version, new_resource.prefix_url, new_resource.binary_url)
version new_resource.version
checksum nodejs_binary_checksum(new_resource.binary_checksums) unless new_resource.binary_url
has_binaries %w(bin/node bin/npm bin/npx)
append_env_path new_resource.append_env_path
action :install
end
when 'source'
build_essential 'install build tools'
(new_resource.build_packages || default_build_packages).each do |pkg|
if dnf_python_package?(pkg)
execute 'install python3 build package' do
command 'dnf -y install python3'
not_if 'command -v python3'
only_if 'command -v dnf'
end
else
package pkg
end
end
link '/usr/local/bin/python' do
to '/usr/bin/python3'
not_if { ::File.exist?('/usr/bin/python') || ::File.exist?('/usr/local/bin/python') }
only_if { ::File.exist?('/usr/bin/python3') }
end
ark 'nodejs-source' do
url nodejs_source_url(new_resource.version, new_resource.prefix_url, new_resource.source_url)
version new_resource.version
checksum new_resource.source_checksum if new_resource.source_checksum
make_opts ["-j #{new_resource.make_threads || default_make_threads}"]
environment(PYTHON: 'python3')
action :install_with_make
end
when 'chocolatey'
chocolatey_package new_resource.chocolatey_package_name do
version new_resource.version if new_resource.version
action :upgrade
end
end
end
action :remove do
case requested_install_method
when 'package'
resolved_packages.each do |pkg|
package pkg do
action :remove
end
end
nodejs_repository 'nodesource' do
action :remove
only_if { new_resource.install_repository }
end
when 'binary'
ark 'nodejs-binary' do
action :remove
end
when 'source'
ark 'nodejs-source' do
action :remove
end
when 'chocolatey'
chocolatey_package new_resource.chocolatey_package_name do
action :remove
end
end
end
action_class do
include NodeJs::Helper
def requested_install_method
new_resource.install_method || default_install_method
end
def resolved_packages
new_resource.packages || default_packages(new_resource.install_repository)
end
def disable_dnf_module?
new_resource.disable_dnf_module &&
platform_family?('rhel', 'fedora') &&
node['platform_version'].to_i >= 8 &&
dnf_module_available?('nodejs')
end
def dnf_module_available?(module_name)
shell_out!("dnf -q module list #{module_name}", returns: [0, 1]).stdout.match?(/^#{Regexp.escape(module_name)}\s/m)
end
end
@@ -0,0 +1,46 @@
# frozen_string_literal: true
provides :nodejs_npm_install
unified_mode true
use '_partial/_nodejs'
property :install_method, String, equal_to: %w(embedded source), default: 'embedded'
property :install_node, [true, false], default: true
property :node_install_method, String, equal_to: %w(package binary source chocolatey), default: 'package'
property :npm_version, String, default: 'latest'
property :npm_url, [String, nil]
property :npm_checksum, [String, nil]
property :make_threads, [Integer, String, nil], default: nil
default_action :install
action :install do
nodejs_install 'nodejs for npm' do
install_method new_resource.node_install_method
version new_resource.version
prefix_url new_resource.prefix_url
action :install
only_if { new_resource.install_node }
end
ark 'npm' do
url lazy { npm_dist(new_resource.npm_version, new_resource.npm_url)['url'] }
checksum new_resource.npm_checksum if new_resource.npm_checksum
version lazy { npm_dist(new_resource.npm_version, new_resource.npm_url)['version'] || new_resource.npm_version }
make_opts ["-j #{new_resource.make_threads || default_make_threads}"]
action :install_with_make
only_if { new_resource.install_method == 'source' }
end
end
action :remove do
ark 'npm' do
action :remove
only_if { new_resource.install_method == 'source' }
end
end
action_class do
include NodeJs::Helper
end
@@ -0,0 +1,46 @@
# frozen_string_literal: true
provides :nodejs_npm_packages
unified_mode true
property :packages, Array, default: []
default_action :install
action :install do
new_resource.packages.each do |pkg|
package_properties = normalize_package(pkg)
pkg_action = package_properties.delete(:action) || :install
pkg_name = package_properties.delete(:package)
npm_package "nodejs_npm-#{pkg_name}-#{pkg_action}" do
package pkg_name
package_properties.each do |property_name, property_value|
send(property_name, property_value)
end
action pkg_action.to_sym
end
end
end
action :remove do
new_resource.packages.each do |pkg|
package_properties = normalize_package(pkg)
pkg_name = package_properties[:package]
npm_package "nodejs_npm-#{pkg_name}-remove" do
package pkg_name
action :remove
end
end
end
action_class do
def normalize_package(pkg)
pkg.each_with_object({}) do |(key, value), memo|
property_name = key.to_sym
property_name = :package if property_name == :name
memo[property_name] = value
end
end
end
@@ -0,0 +1,78 @@
# frozen_string_literal: true
provides :nodejs_repository
unified_mode true
property :repo_name, String, name_property: true
property :node_major, [String, Integer], default: '24'
property :apt_uri, String
property :apt_distribution, String, default: 'nodistro'
property :apt_components, Array, default: ['main']
property :apt_key, String, default: 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key'
property :apt_keyring, String, default: '/etc/apt/keyrings/nodesource.asc'
property :apt_pin_priority, String, default: '600'
property :yum_baseurl, String
property :yum_gpgkey, String, default: 'https://rpm.nodesource.com/gpgkey/ns-operations-public.key'
property :yum_priority, String, default: '9'
property :enabled, [true, false], default: true
property :gpgcheck, [true, false], default: true
default_action :create
action :create do
case node['platform_family']
when 'debian'
package %w(ca-certificates curl gnupg apt-transport-https)
directory ::File.dirname(new_resource.apt_keyring) do
recursive true
mode '0755'
end
remote_file new_resource.apt_keyring do
source new_resource.apt_key
mode '0644'
end
apt_preference new_resource.repo_name do
glob '*'
pin 'origin deb.nodesource.com'
pin_priority new_resource.apt_pin_priority
end
apt_repository new_resource.repo_name do
uri lazy { new_resource.apt_uri || "https://deb.nodesource.com/node_#{new_resource.node_major}.x" }
components new_resource.apt_components
signed_by new_resource.apt_keyring
distribution new_resource.apt_distribution
end
when 'rhel', 'fedora', 'amazon'
yum_repository "#{new_resource.repo_name}-nodejs" do
description 'nodesource.com nodejs repository'
baseurl lazy { new_resource.yum_baseurl || "https://rpm.nodesource.com/pub_#{new_resource.node_major}.x/nodistro/nodejs/$basearch" }
gpgkey new_resource.yum_gpgkey
priority new_resource.yum_priority
enabled new_resource.enabled
gpgcheck new_resource.gpgcheck
options(module_hotfixes: 1)
action :create
end
end
end
action :remove do
case node['platform_family']
when 'debian'
apt_repository new_resource.repo_name do
action :remove
end
file new_resource.apt_keyring do
action :delete
end
when 'rhel', 'fedora', 'amazon'
yum_repository "#{new_resource.repo_name}-nodejs" do
action :remove
end
end
end
+29 -31
View File
@@ -1,28 +1,8 @@
#
# Cookbook:: nodejs
# Resource:: npm
#
# Author:: Sergey Balbeko <sergey@balbeko.com>
#
# Copyright:: 2012-2017, Sergey Balbeko
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# frozen_string_literal: true
resource_name :npm_package
provides :npm_package
unified_mode true
# backwards compatibility for the old resource name
provides :nodejs_npm
property :package, String, name_property: true
@@ -30,7 +10,7 @@ property :version, String
property :path, String
property :url, String
property :json, [String, true, false]
property :npm_token, String
property :npm_token, String, sensitive: true
property :options, Array, default: []
property :user, String
property :group, String
@@ -38,10 +18,7 @@ property :live_stream, [false, true], default: false
property :node_env, String
property :auto_update, [true, false], default: true
def initialize(*args)
super
@run_context.include_recipe 'nodejs::npm' if node['nodejs']['manage_node']
end
default_action :install
action :install do
execute "install NPM package #{new_resource.package}" do
@@ -51,7 +28,8 @@ action :install do
group new_resource.group
environment npm_env_vars
live_stream new_resource.live_stream
not_if { package_installed? && no_auto_update? }
sensitive true if new_resource.npm_token
not_if { no_auto_update? && package_installed? }
end
end
@@ -63,6 +41,20 @@ action :uninstall do
group new_resource.group
environment npm_env_vars
live_stream new_resource.live_stream
sensitive true if new_resource.npm_token
only_if { package_installed? }
end
end
action :remove do
execute "uninstall NPM package #{new_resource.package}" do
cwd new_resource.path
command "npm uninstall #{npm_options}"
user new_resource.user
group new_resource.group
environment npm_env_vars
live_stream new_resource.live_stream
sensitive true if new_resource.npm_token
only_if { package_installed? }
end
end
@@ -75,13 +67,19 @@ action_class do
env_vars['HOME'] = ::Dir.home(new_resource.user) if new_resource.user
env_vars['USER'] = new_resource.user if new_resource.user
env_vars['NPM_TOKEN'] = new_resource.npm_token if new_resource.npm_token
env_vars['NODE_ENV'] = new_resource.node_env if new_resource.node_env
env_vars['NODE_ENV'] = new_resource.node_env if new_resource.node_env
env_vars
end
def package_installed?
new_resource.package && npm_package_installed?(new_resource.package, new_resource.version, new_resource.path, new_resource.npm_token)
return package_json_installed? if new_resource.json == true
new_resource.package && npm_package_installed?(new_resource.package, new_resource.version, new_resource.path, npm_env_vars)
end
def package_json_installed?
new_resource.path && ::File.exist?(::File.join(new_resource.path, 'node_modules'))
end
def no_auto_update?
@@ -89,7 +87,7 @@ action_class do
end
def npm_options
options = ''
options = +''
options << ' -global' unless new_resource.path
new_resource.options.each do |option|
options << " #{option}"
@@ -1,18 +1,18 @@
{
"name": "akkounts-1",
"name": "akkounts-2",
"chef_environment": "production",
"normal": {
"knife_zero": {
"host": "10.1.1.144"
"host": "10.1.1.120"
},
"vm_host": "draco"
"vm_host": "leo"
},
"automatic": {
"fqdn": "akkounts-1",
"fqdn": "akkounts-2",
"os": "linux",
"os_version": "5.4.0-223-generic",
"hostname": "akkounts-1",
"ipaddress": "192.168.122.160",
"os_version": "6.8.0-134-generic",
"hostname": "akkounts-2",
"ipaddress": "192.168.122.157",
"roles": [
"base",
"kvm_guest",
@@ -38,8 +38,6 @@
"apt::default",
"timezone_iii::default",
"timezone_iii::debian",
"ntp::default",
"ntp::apparmor",
"kosmos-base::journald_conf",
"kosmos-base::systemd_emails",
"apt::unattended-upgrades",
@@ -51,21 +49,10 @@
"postfix::sasl_auth",
"hostname::default",
"firewall::default",
"redisio::default",
"redisio::_install_prereqs",
"redisio::install",
"redisio::ulimit",
"redisio::disable_os_default",
"redisio::configure",
"redisio::enable",
"kosmos-nodejs::default",
"nodejs::nodejs_from_package",
"nodejs::repo",
"nodejs::npm",
"nodejs::install"
"kosmos-nodejs::default"
],
"platform": "ubuntu",
"platform_version": "20.04",
"platform_version": "24.04",
"cloud": null,
"chef_packages": {
"chef": {
+18
View File
@@ -22,6 +22,7 @@
"kosmos-base",
"kosmos-base::default",
"kosmos_prometheus::node_exporter",
"kosmos_zerotier::ohai_plugin",
"kosmos_kvm::guest",
"kosmos_prometheus::server",
"kosmos_prometheus::alertmanager",
@@ -38,6 +39,7 @@
"postfix::_attributes",
"postfix::sasl_auth",
"hostname::default",
"zerotier::ohai_plugin",
"firewall::default"
],
"platform": "ubuntu",
@@ -53,6 +55,22 @@
"version": "18.2.13",
"ohai_root": "/opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.2.13/lib/ohai"
}
},
"zerotier": {
"version": "1.16.2",
"node_id": "77fcedcdce",
"networks": {
"8541e5153eb4327c": {
"network_name": "virgo",
"mac": "7e:45:48:d3:d8:2b",
"status": "OK",
"type": "PRIVATE",
"interface": "ztsb7vcj2c",
"addresses": [
"10.1.1.146/24"
]
}
}
}
},
"run_list": [
+3 -3
View File
@@ -9,7 +9,7 @@
"automatic": {
"fqdn": "rs-discourse-1",
"os": "linux",
"os_version": "5.4.0-1118-kvm",
"os_version": "5.4.0-1133-kvm",
"hostname": "rs-discourse-1",
"ipaddress": "192.168.122.30",
"roles": [
@@ -39,8 +39,8 @@
"postfix::_attributes",
"postfix::sasl_auth",
"hostname::default",
"firewall::default",
"discourse::default"
"discourse::default",
"firewall::default"
],
"platform": "ubuntu",
"platform_version": "20.04",
+1
View File
@@ -3,4 +3,5 @@ name "base"
run_list %w(
kosmos-base::default
kosmos_prometheus::node_exporter
kosmos_zerotier::ohai_plugin
)
-69
View File
@@ -1,69 +0,0 @@
#!/usr/bin/env bash
# Strip the top-level "override" and "default" attributes from Chef node JSON files.
#
# Usage:
# ./scripts/util/strip_node_attrs.sh <node> [<node> ...]
# ./scripts/util/strip_node_attrs.sh --all
#
# A <node> may be a bare node name (e.g. "prometheus-1"), a path relative to the
# repository root (e.g. "nodes/prometheus-1.json"), or an absolute path.
#
# Exit codes:
# 0 - all target files processed successfully
# 1 - one or more targets could not be processed (missing args, missing jq,
# file not found, invalid JSON, or write failure)
set -uo pipefail
command -v jq >/dev/null 2>&1 || exit 1
root="$(git rev-parse --show-toplevel 2>/dev/null)" || root="$(pwd)"
targets=()
if [ "$#" -eq 0 ]; then
exit 1
fi
for arg in "$@"; do
if [ "$arg" = "--all" ]; then
shopt -s nullglob
for f in "$root"/nodes/*.json; do
targets+=("$f")
done
shopt -u nullglob
continue
fi
if [[ "$arg" == */* ]]; then
if [[ "$arg" = /* ]]; then
targets+=("$arg")
else
targets+=("$root/$arg")
fi
else
targets+=("$root/nodes/$arg.json")
fi
done
if [ "${#targets[@]}" -eq 0 ]; then
exit 1
fi
rc=0
for file in "${targets[@]}"; do
[ -f "$file" ] || { rc=1; continue; }
jq -e . "$file" >/dev/null 2>&1 || { rc=1; continue; }
tmp="$(mktemp "${file}.XXXXXX")" || { rc=1; continue; }
if jq --indent 2 'del(.override, .default)' "$file" > "$tmp" 2>/dev/null; then
truncate -s -1 "$tmp" 2>/dev/null || true
mv "$tmp" "$file" || { rm -f "$tmp"; rc=1; continue; }
else
rm -f "$tmp"
rc=1
continue
fi
done
exit "$rc"
@@ -26,6 +26,8 @@ systemd_unit "discourse.service" do
Environment: "SUPERVISED=true",
ExecStart: "#{deploy_path}/launcher start app",
ExecStop: "#{deploy_path}/launcher stop app",
TimeoutStartSec: '300',
TimeoutStopSec: '30'
},
Install: {
WantedBy: "multi-user.target"
+1 -2
View File
@@ -4,12 +4,11 @@ maintainer_email 'mail@kosmos.org'
license 'MIT'
description 'Installs/configures kosmos-akkounts'
long_description 'Installs/configures kosmos-akkounts'
version '0.2.0'
version '0.3.0'
chef_version '>= 18.0'
depends 'kosmos_openresty'
depends "kosmos-nodejs"
depends "redisio"
depends "postgresql"
depends "kosmos_postgresql"
depends "backup"
@@ -19,13 +19,16 @@ user deploy_user do
shell "/bin/bash"
end
directory deploy_path do
owner deploy_user
group deploy_group
mode "0755"
end
package "libpq-dev"
package "libvips"
include_recipe 'redisio::default'
include_recipe 'redisio::enable'
node.override["nodejs"]["repo"] = "https://deb.nodesource.com/node_20.x"
node.override["kosmos_nodejs"]["version"] = "22.23.1"
include_recipe 'kosmos-nodejs'
npm_package "bun"
@@ -34,7 +37,7 @@ ruby_path = "/opt/ruby_build/builds/#{ruby_version}"
bundle_path = "#{ruby_path}/bin/bundle"
rails_env = node.chef_environment == "development" ? "development" : "production"
ruby_build_install 'v20240221'
ruby_build_install 'v20260701'
ruby_build_definition ruby_version do
prefix_path ruby_path
end
@@ -221,7 +224,6 @@ systemd_unit "akkounts.service" do
Unit: {
Description: "Kosmos Accounts",
Documentation: ["https://gitea.kosmos.org/kosmos/akkounts"],
Requires: "redis@6379.service",
After: "syslog.target network.target"
},
Service: {
@@ -0,0 +1,8 @@
allowed_automatic_attributes ["fqdn", "os", "os_version", "hostname",
"ipaddress", "roles", "recipes", "ipaddress",
"platform", "platform_version", "cloud",
"cloud_v2", "chef_packages", "zerotier"]
allowed_default_attributes []
allowed_override_attributes []
allowed_normal_attributes ["knife_zero", "kosmos_kvm", "kosmos-ejabberd",
"openresty", "vm_host"]
@@ -1,6 +0,0 @@
---
- knife_zero
- kosmos_kvm
- kosmos-ejabberd
- openresty
- vm_host
+22 -48
View File
@@ -2,57 +2,31 @@
# Cookbook Name:: kosmos-base
# Recipe:: default
#
# The MIT License (MIT)
#
# Copyright:: 2019, Kosmos Developers
#
# 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:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
ruby_block "cleanup client.rb" do
block do
fe = Chef::Util::FileEdit.new("/etc/chef/client.rb")
# Delete old attributes, replaced by allow_*_attributes
fe.search_file_delete_line(/^.*_attribute_whitelist.*/)
fe.write_file
end
end
cookbook_file "/etc/chef/client.d/attributes.rb" do
source "chef_attributes.rb"
mode "0644"
notifies :create, "ruby_block[reload_client_config]", :immediately
end
ruby_block "reload_client_config" do
block do
Chef::Config.from_file("/etc/chef/client.rb")
end
action :nothing
end
include_recipe "apt"
cookbook_file "/etc/chef/chef_normal_attributes.yml" do
source "chef_normal_attributes.yml"
owner "root"
group "root"
mode "0644"
end
ruby_block "update allowed_normal_attributes in client.rb" do
block do
whitelist = YAML.load_file("/etc/chef/chef_normal_attributes.yml")
fe = Chef::Util::FileEdit.new("/etc/chef/client.rb")
fe.search_file_replace_line(
/^allowed_normal_attributes.*/,
"allowed_normal_attributes #{whitelist.inspect}"
)
fe.write_file
Chef::Config[:allowed_normal_attributes] = whitelist
Chef::Config[:normal_attribute_allowlist] = whitelist
end
not_if do
whitelist = YAML.load_file("/etc/chef/chef_normal_attributes.yml")
client_rb = ::File.read("/etc/chef/client.rb")
whitelist.all? { |attr| client_rb.include?(attr) }
end
end
directory "/etc/apt/keyrings" do
mode "0755"
action :create
+1 -1
View File
@@ -3,7 +3,7 @@
# Recipe:: rtl
#
node.override["nodejs"]["repo"] = "https://deb.nodesource.com/node_18.x"
node.override["kosmos_nodejs"]["version"] = "18.20.8"
include_recipe 'kosmos-nodejs'
app_name = "rtl"
@@ -3,6 +3,5 @@
# Recipe:: _nodejs
#
node.override["nodejs"]["repo"] = "https://deb.nodesource.com/node_16.x"
node.override["kosmos_nodejs"]["version"] = "16.20.2"
include_recipe "kosmos-nodejs"
@@ -3,8 +3,7 @@
# Recipe:: kredits_pinner
#
node.override["nodejs"]["repo"] = "https://deb.nodesource.com/node_16.x"
node.override["kosmos_nodejs"]["version"] = "16.20.2"
include_recipe 'kosmos-nodejs'
app_name = "ipfs-pinner"
@@ -3,7 +3,7 @@
# Recipe:: default
#
node.override["nodejs"]["repo"] = "https://deb.nodesource.com/node_18.x"
node.override["kosmos_nodejs"]["version"] = "18.20.8"
include_recipe "kosmos-nodejs"
include_recipe "java"
@@ -1,3 +1 @@
node.override["nodejs"]["repo"] = "https://deb.nodesource.com/node_14.x"
# Allows upgrading
node.override["nodejs"]["package_action"]["nodejs"] = :upgrade
node.default["kosmos_nodejs"]["version"] = "14.21.3"
@@ -3,4 +3,7 @@
# Recipe:: default
#
include_recipe "nodejs::nodejs_from_package"
nodejs_install 'nodejs' do
install_method 'package'
version node["kosmos_nodejs"]["version"]
end
@@ -7,7 +7,7 @@
include_recipe "git"
node.override["nodejs"]["repo"] = "https://deb.nodesource.com/node_20.x"
node.override["kosmos_nodejs"]["version"] = "20.20.2"
include_recipe 'kosmos-nodejs'
node.override["golang"]["version"] = "1.23.9"
@@ -12,10 +12,11 @@ node.default["kosmos_prometheus"]["alertmanager"]["checksum"] = "8ce11c42e8a6dfb
node.default["kosmos_prometheus"]["node_exporter"]["version"] = "1.11.1"
node.default["kosmos_prometheus"]["node_exporter"]["checksum"] = "9f5ea48e5bc7b656f8a91a32e7d7deb89f70f73dabd0d974418aca15f37d6810"
node.default["kosmos_prometheus"]["node_exporter"]["port"] = 9100
node.default["kosmos_prometheus"]["alertmanager"]["route"] = {
"receiver" => "xmpp",
"group_by" => ["alertname"],
"group_by" => ["alertname", "severity"],
"group_wait" => "20s",
"group_interval" => "30s",
"repeat_interval" => "3h",
@@ -32,6 +33,8 @@ node.default["kosmos_prometheus"]["alertmanager"]["route"] = {
],
}
node.default["kosmos_prometheus"]["alertmanager"]["port"] = 9093
node.default["kosmos_prometheus"]["alertmanager"]["receivers"] = [
{
"name" => "xmpp",
@@ -64,7 +67,7 @@ node.default["kosmos_prometheus"]["global"] = {
node.default["kosmos_prometheus"]["alerting"] = {
"alertmanagers" => [
"static_configs" => [
{ "targets" => ["127.0.0.1:9093"] }
{ "targets" => ["127.0.0.1:#{node["kosmos_prometheus"]["alertmanager"]["port"]}"] }
]
]
}
@@ -8,3 +8,87 @@ groups:
severity: warning
annotations:
summary: "Node is down"
- alert: NodeFilesystemAlmostOutOfSpace
expr: |
(node_filesystem_avail_bytes{fstype!~"tmpfs|fuse.lxcfs|overlay|squashfs|ramfs",mountpoint!~"/run.*|/var/lib/docker/.*"}
/ node_filesystem_size_bytes{fstype!~"tmpfs|fuse.lxcfs|overlay|squashfs|ramfs",mountpoint!~"/run.*|/var/lib/docker/.*"}) * 100 < 10
for: 5m
labels:
severity: warning
annotations:
summary: "Filesystem has < 10% free space"
- alert: NodeFilesystemAlmostOutOfSpace
expr: |
(node_filesystem_avail_bytes{fstype!~"tmpfs|fuse.lxcfs|overlay|squashfs|ramfs",mountpoint!~"/run.*|/var/lib/docker/.*"}
/ node_filesystem_size_bytes{fstype!~"tmpfs|fuse.lxcfs|overlay|squashfs|ramfs",mountpoint!~"/run.*|/var/lib/docker/.*"}) * 100 < 5
for: 5m
labels:
severity: critical
annotations:
summary: "Filesystem has < 5% free space"
- alert: NodeFilesystemAlmostOutOfInodes
expr: (node_filesystem_files_free / node_filesystem_files) * 100 < 10
for: 5m
labels:
severity: warning
annotations:
summary: "Filesystem has < 10% free inodes"
- alert: NodeFilesystemReadOnly
expr: node_filesystem_readonly == 1
for: 2m
labels:
severity: critical
annotations:
summary: "Filesystem remounted read-only"
- alert: NodeMemoryHigh
expr: (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100 > 90
for: 10m
labels:
severity: warning
annotations:
summary: "Memory usage > 90%"
- alert: NodeMemoryHigh
expr: (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100 > 95
for: 5m
labels:
severity: critical
annotations:
summary: "Memory usage > 95%"
- alert: NodeSwapHigh
expr: (node_memory_SwapTotal_bytes > 0) and ((1 - node_memory_SwapFree_bytes / node_memory_SwapTotal_bytes) * 100 > 50)
for: 10m
labels:
severity: warning
annotations:
summary: "Swap usage > 50%"
- alert: NodeCpuHigh
expr: 100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 80
for: 10m
labels:
severity: warning
annotations:
summary: "CPU usage > 80% for 10m"
- alert: NodeCpuHigh
expr: 100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 95
for: 5m
labels:
severity: critical
annotations:
summary: "CPU usage > 95% for 5m"
- alert: NodeLoadHigh
expr: node_load1 / count by (instance) (node_cpu_seconds_total{mode="idle"}) > 1.5
for: 10m
labels:
severity: warning
annotations:
summary: "System load1 > 1.5x CPU cores"
@@ -10,6 +10,8 @@ checksum = node["kosmos_prometheus"]["alertmanager"]["checksum"]
tarball = "#{Chef::Config[:file_cache_path]}/alertmanager-#{version}.linux-amd64.tar.gz"
binary_url = "https://github.com/prometheus/alertmanager/releases/download/v#{version}/alertmanager-#{version}.linux-amd64.tar.gz"
alertmanager_port = node["kosmos_prometheus"]["alertmanager"]["port"]
group "alertmanager"
user "alertmanager" do
@@ -81,7 +83,7 @@ systemd_unit "alertmanager.service" do
Type: "simple",
User: "alertmanager",
Group: "alertmanager",
ExecStart: "/usr/local/bin/alertmanager --config.file=/etc/prometheus/alertmanager.yml --storage.path=/var/lib/alertmanager --web.listen-address=:9093",
ExecStart: "/usr/local/bin/alertmanager --config.file=/etc/prometheus/alertmanager.yml --storage.path=/var/lib/alertmanager --web.listen-address=:#{alertmanager_port}",
Restart: "on-failure",
RestartSec: "5",
},
@@ -98,7 +100,7 @@ service "alertmanager" do
end
firewall_rule "prometheus alertmanager" do
port 9093
port alertmanager_port
source "10.1.1.0/24"
protocol :tcp
command :allow
@@ -8,6 +8,8 @@ checksum = node["kosmos_prometheus"]["node_exporter"]["checksum"]
tarball = "#{Chef::Config[:file_cache_path]}/node_exporter-#{version}.linux-amd64.tar.gz"
binary_url = "https://github.com/prometheus/node_exporter/releases/download/v#{version}/node_exporter-#{version}.linux-amd64.tar.gz"
node_exporter_port = node["kosmos_prometheus"]["node_exporter"]["port"]
group "node_exporter"
user "node_exporter" do
@@ -56,7 +58,7 @@ systemd_unit "node_exporter.service" do
Type: "simple",
User: "node_exporter",
Group: "node_exporter",
ExecStart: "/usr/local/bin/node_exporter --web.listen-address=:9100 --collector.textfile.directory=/var/lib/node_exporter/textfile",
ExecStart: "/usr/local/bin/node_exporter --web.listen-address=:#{node_exporter_port} --collector.textfile.directory=/var/lib/node_exporter/textfile",
Restart: "on-failure",
RestartSec: "5",
NoNewPrivileges: "yes",
@@ -76,7 +78,7 @@ service "node_exporter" do
end
firewall_rule "node_exporter" do
port 9100
port node_exporter_port
source "10.1.1.0/24"
protocol :tcp
command :allow
@@ -82,7 +82,7 @@ jobs = node["kosmos_prometheus"]["jobs"].merge(
# node exporter
"node" => {
"query" => "role:base",
"port" => 9100
"port" => node["kosmos_prometheus"]["node_exporter"]["port"]
},
# garage metrics
"garage" => {
+2 -1
View File
@@ -4,7 +4,8 @@ maintainer_email 'mail@kosmos.org'
license 'MIT'
description 'Installs/Configures zerotier'
long_description 'Installs/Configures zerotier'
version '0.1.0'
version '0.2.0'
chef_version '>= 14.0'
depends 'kosmos-base'
depends 'zerotier'
@@ -0,0 +1,21 @@
#
# Cookbook:: kosmos_zerotier
# Recipe:: ohai_plugin
#
include_recipe "zerotier::ohai_plugin"
ohai "reload_zerotier" do
action :reload
plugin "zerotier"
notifies :run, "ruby_block[save_chef_zero_node]", :delayed
end
# Force save the node back to disk in Chef Zero
ruby_block "save_chef_zero_node" do
block do
node.save
Chef::Log.info("Node #{node.name} saved to disk with ZeroTier data")
end
action :nothing
end
@@ -5,6 +5,8 @@
include_recipe 'redisio::default'
include_recipe 'redisio::enable'
node.override["kosmos_nodejs"]["version"] = "24.18.0"
include_recipe 'kosmos-nodejs'
user = "sockethub"