From 6c2c4111754453af1a2f676128b8319418dff48f Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Sat, 28 Oct 2023 19:06:44 +0200 Subject: [PATCH] only ensure real npm packages nodesource's `nodejs` packages have `Provides: npm` which means that when we try to `ensure => absent` the `npm` package, it really removes the `nodejs` package we want. by setting `allow_virtual => false` when using nodesource packages, we ensure that we only remove real packages. Fixes: 160ea93dbc6f6633d01f0a078541bbad21ad93ba --- manifests/install.pp | 12 ++++++++++-- manifests/params.pp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index e6db8d04..993bb817 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -45,9 +45,17 @@ # npm if $nodejs::npm_package_name and $nodejs::npm_package_name != false { + # the nodesource nodejs packages provide "npm" which makes Puppet + # try to uninstall them again + if $nodejs::npm_package_ensure == absent and $nodejs::manage_package_repo == true and $nodejs::repo_class == 'nodejs::repo::nodesource' { + $allow_virtual = false + } else { + $allow_virtual = undef + } package { $nodejs::npm_package_name: - ensure => $nodejs::npm_package_ensure, - tag => 'nodesource_repo', + ensure => $nodejs::npm_package_ensure, + allow_virtual => $allow_virtual, + tag => 'nodesource_repo', } } diff --git a/manifests/params.pp b/manifests/params.pp index ff11fa3f..32e7c7a4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -41,7 +41,7 @@ $nodejs_dev_package_name = 'nodejs-devel' $nodejs_dev_package_ensure = 'absent' $nodejs_package_name = 'nodejs' - $npm_package_ensure = 'present' + $npm_package_ensure = 'absent' $npm_package_name = 'npm' $npm_path = '/usr/bin/npm' $repo_class = 'nodejs::repo::nodesource'