简体   繁体   English

Vagrant,Puppet和nodejs模块:在npm模块安装上抛出错误

[英]Vagrant, Puppet and nodejs module: throwing error on npm module installation

I have the following manifest: 我有以下清单:

include nodejs

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

I am using the puppetlab node.js module: 我正在使用puppetlab node.js模块:

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

Vagrantfile: 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: 当我运行vagrant up我收到以下错误:

[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. 起初我想也许它正在尝试在安装npm之前安装'serve'模块,所以我尝试了require => Package[npm]但是得到了相同的结果。

So could anybody shine some light on why it's not installing the 'serve' module? 所以有人可以说明为什么它不安装'服务'模块?

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. 我也碰到了这个 - 它看起来像puppetlabs-nodejs模块实际上不接受ensure => latest ,这与文档相反。 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. 当我更改为ensure => present ,我的问题已修复,并且代码确实支持特定版本,例如ensure => 1.12.4

It seems to be ordering - the provider needs the npm command, which you don't have yet. 它似乎是在排序 - 提供者需要npm命令,你还没有。

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'],
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM