I'm trying to install node.js on a Vagrant box using puppet. My Vagrantfile (Debian Wheezy) has the following configuration:
config.vm.provision :puppet, run: "always" do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.module_path = "puppet/modules"
puppet.options = '--verbose'
end
Inside puppet/modules
I have the official puppetlabs-nodejs
module (renamed to just nodejs
). Inside puppet/manifests
I'm starting out small - default.pp
is just this:
Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
include nodejs
When I run vagrant provision
I get the following errors:
==> 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:
Far as I can tell I'm following the readme . Is that readme incomplete? Is there more to installing node than just including the module?
Instead of using an exec, you could use the manage_package_repo
parameter:
package { 'nodejs':
ensure => present,
manage_package_repo => true,
}
This will run this Puppet code (which is the same as the exec, but more idempotent!)
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',
}
}
You need to add run the following first to pull in the pointers to the packages.
curl -sL https://deb.nodesource.com/setup | sudo bash -
You will need an exec
block to do this.
exec block with that command, and creates set to '/etc/apt/sources.list.d/nodesource.list'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.