通过 puppet 安装 node.js;找不到包

installing node.js via puppet; package not found

我正在尝试使用 puppet 在 Vagrant box 上安装 node.js。我的 Vagrantfile (Debian Wheezy) 具有以下配置:

config.vm.provision :puppet, run: "always" do |puppet|
  puppet.manifests_path = "puppet/manifests"
  puppet.module_path = "puppet/modules"
  puppet.options = '--verbose'
end

puppet/modules 里面我有官方的 puppetlabs-nodejs 模块(重命名为 nodejs)。 puppet/manifests 我从小处着手 - default.pp 就是这样:

Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
include nodejs

当我 运行 vagrant provision 我得到以下错误:

==> default: err: /Stage[main]/Nodejs/Package[nodejs]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install nodejs' returned 100: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: E: Unable to locate package nodejs
==> default: 
==> default: err: /Stage[main]/Nodejs/Package[npm]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install npm' returned 100: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: E: Unable to locate package npm
==> default: 

据我所知,我正在关注 the readme。自述文件不完整吗?除了包含模块之外,安装节点还有更多吗?

您需要先添加 运行 以下内容以引入指向包的指针。

curl -sL https://deb.nodesource.com/setup | sudo bash -

您将需要一个 exec 块来执行此操作。

exec 使用该命令块,并创建设置为 '/etc/apt/sources.list.d/nodesource.list'

您可以使用 manage_package_repo 参数代替 exec:

  package { 'nodejs':
    ensure              => present,
    manage_package_repo => true,
  }

这将 运行 这个 Puppet 代码(与 exec 相同,但更幂等!)

if ($ensure == 'present') {
    apt::source { 'nodesource':
      include_src       => $enable_src,
      key               => '1655A0AB68576280',
      key_source        => 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key',
      location          => 'https://deb.nodesource.com/node',
      pin               => $pin,
      release           => $::lsbdistcodename,
      repos             => 'main',
      required_packages => 'apt-transport-https ca-certificates',
    }
  }