Trying to get some NPM packages installed both locally and globally. I am doing it like this:
$npm_packages_loc = {
'mysql' => {
'version' => 'latest',
'ensure' => 'present',
},
'googleapis' => {
'version' => 'latest',
'ensure' => 'present',
}
}
This simply says that I want the 'mysql' and 'googleapi' packages installed, and I want them at the latest version.
## Install NPM local packages
# Obtains and multiplexes NPM packages defgined in '$npm_modules_loc'
define npm_packages($version, $ensure) {
npm_packages_loc_inst { $version:
package => $name,
ensure => $ensure,
}
}
# Installs the packages via nodejs::npm
define npm_packages_loc_inst($package, $ensure) {
$version = name
nodejs::npm { "/opt/app/:${package}":
ensure => $ensure,
version => $version,
}
}
create_resources ('npm_packages', $npm_packages_loc)
However, when doing a puppet run I get the following error:
Duplicate declaration: myapp::Npm_packages_loc_inst[latest] is already declared in file /etc/puppet/modules/test/myapp/manifests/init.pp:79; cannot redeclare at /etc/puppet/modules/test/myapp/manifests/init.pp:79
Not sure why it is behaving like this, but I am obviously doing something wrong. Any help is appreciated :)