6

I have the following manifest:

include nodejs

package { 'serve':
  ensure => latest,
  provider => 'npm',
}

I am using the puppetlab node.js module:

http://forge.puppetlabs.com/puppetlabs/nodejs

Vagrantfile:

Vagrant::Config.run do |config|
  config.vm.box = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"

  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = '~/work/environments/default/'
    puppet.manifest_file = 'site.pp'
    puppet.module_path = '~/work/environments/default/modules'
  end

end

When I run vagrant up I am getting the following error:

[default] Running provisioner: Vagrant::Provisioners::Puppet...
[default] Running Puppet with /tmp/vagrant-puppet/manifests/site.pp...
stdin: is not a tty
err: /Stage[main]//Package[serve]/ensure: change from absent to latest failed: Could not update: Got nil value for ensure at /tmp/vagrant-puppet/manifests/site.pp:6
notice: /Stage[main]/Nodejs/Package[nodejs]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[main]/Nodejs/Package[npm]/ensure: ensure changed 'purged' to 'present'
notice: Finished catalog run in 14.89 seconds

At first I thought maybe it's trying to install the 'serve' module before npm installed so I tried require => Package[npm] but that gave the same result.

So could anybody shine some light on why it's not installing the 'serve' module?

Pickels
  • 33,902
  • 26
  • 118
  • 178

2 Answers2

11

I ran across this as well - it looks to me like the puppetlabs-nodejs module doesn't actually accept ensure => latest, which is contrary to the documentation. My issue was fixed when I changed to ensure => present, and the code does look to support specific versions as well with ensure => 1.12.4 for example.

Logickal
  • 141
  • 1
  • 3
  • There's a pull request open to fix this, but it's currently failing its Travis build if anybody wants to help correct that: https://github.com/puppetlabs/puppetlabs-nodejs/pull/78 – Scott Buchanan Feb 16 '15 at 17:41
8

It seems to be ordering - the provider needs the npm command, which you don't have yet.

Try altering your manifest to something like:

class { 'nodejs': } -> package { 'serve': ensure => present, provider => 'npm', }

alternatively, possibly:

include nodejs

package { 'serve':
  ensure => present,
  provider => 'npm',
  require => Package['npm'],
}
Whymarrh
  • 13,139
  • 14
  • 57
  • 108