我正在尝试使用Vagrant安装VM。
错误讯息:
Unable to load puppet. Please install it using native packages for your platform (eg .deb, .rpm, .dmg, etc).
puppet --version returned pid 4696 exit 1
答案 0 :(得分:2)
我发现Hashicorp提供的脚本可以处理我的大多数流浪/木偶引导需求。您可以在https://github.com/hashicorp/puppet-bootstrap
找到它们以下是我在包含库管理程序的Vagrant文件中使用它的示例:
# Vagrantfile default
# 2012-2014 3E Enterprises, LLC
# This configuration will set up a default base VM provisioned with puppet.
# Assumes the use of VirtualBox 4.3.14-95030 as a provider.
# Uses vagrant-vbguest plugin (https://github.com/dotless-de/vagrant-vbguest)
# to keep VirtualBox Guest Addition wrangled.
# Configuration settings
BOOTSTRAP_SCRIPT = "vagrant_data/base/install.sh"
CPUS = "1"
IP = "192.168.50.4"
MEMORY = "512"
PROVIDER = "virtualbox"
# Eventually change this to a directory when this change hits vagrant (1.6.4?):
# https://github.com/mitchellh/vagrant/pull/4169
# This will kill the deprecation warning.
PUPPET_MANIFEST_FILE = "site.pp"
HIERA_CONFIG_PATH = "puppet/hiera.yaml"
PUPPET_MANIFESTS_PATH = "puppet/manifests"
PUPPET_MODULE_PATH = ["puppet/modules", "puppet/local_modules"]
SYNCED_FOLDER = "/vagrant"
SYNCED_FOLDER_TYPE = "nfs"
VAGRANT_VERSION_REQUIRE = ">= 1.6.5"
VAGRANTFILE_API_VERSION = "2"
VM_BOX = "ubuntu/trusty64"
VM_BOX_VERSION = "14.04"
# Lock down vagrant version.
Vagrant.require_version VAGRANT_VERSION_REQUIRE
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# vagrant-vbguest config
config.vbguest.no_install = false
# vagrant-librarian-puppet config
config.librarian_puppet.puppetfile_dir = "puppet"
config.librarian_puppet.placeholder_filename = ".gitkeep"
# Lock box version down.
config.vm.box = VM_BOX
config.vm.box_version = VM_BOX_VERSION
config.vm.box_check_update = true
config.vm.synced_folder ".", SYNCED_FOLDER, type: SYNCED_FOLDER_TYPE
if Vagrant.has_plugin?("vagrant-cachier")
# Configure cached packages to be shared between instances of the same base box.
# More info on the "Usage" link above
config.cache.scope = :box
# OPTIONAL: If you are using VirtualBox, you might want to use that to enable
# NFS for shared folders. This is also very useful for vagrant-libvirt if you
# want bi-directional sync
# config.cache.synced_folder_opts = {
# type: :nfs,
# # The nolock option can be useful for an NFSv3 client that wants to avoid the
# # NLM sideband protocol. Without this option, apt-get might hang if it tries
# # to lock files needed for /var/cache/* operations. All of this can be avoided
# # by using NFSv4 everywhere. Please note that the tcp option is not the default.
# mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
# }
end
# Run the bootstrap script on every machine.
config.vm.provision :shell, :path => BOOTSTRAP_SCRIPT
# Build the base VM (base):
config.vm.define :"base", primary: true do |base|
base.vm.hostname = "base"
base.vm.network :private_network, ip: IP
base.vm.provision :puppet, run: "always" do |puppet|
puppet.hiera_config_path = HIERA_CONFIG_PATH
puppet.manifests_path = PUPPET_MANIFESTS_PATH
puppet.module_path = PUPPET_MODULE_PATH
puppet.manifest_file = PUPPET_MANIFEST_FILE
end
# Set up VM
base.vm.provider PROVIDER do |v|
v.customize [
"modifyvm", :id,
"--memory", MEMORY,
"--cpus", CPUS
]
end
end
end
祝你好运!
<强>更新强>
以下是我使用的开发环境:http://www.erikevenson.net/posts/2015/3/19/my-basic-development-environment
答案 1 :(得分:0)
我认为这是因为Ubuntu发布了与ruby 1.9不兼容的木偶2.7.X。具体来说,facter.rb似乎不在1.9的加载路径中。
我最终使用和RVM安装ruby 1.8.7,将puppet作为宝石。将系统木偶升级到3.x可能也会起作用。
https://github.com/rodjek/librarian-puppet/issues/99
https://github.com/rodjek/librarian-puppet/pull/134
https://github.com/rodjek/librarian-puppet/pull/162
所以Vagrant中的默认木偶是2.7版本,如果你需要最新的木偶,比如3.7.3,你需要按照以下网址首先在流浪汉中升级木偶。
http://blog.doismellburning.co.uk/2013/01/19/upgrading-puppet-in-vagrant-boxes/
cat upgrade_puppet.sh
#!/bin/bash
apt-get install --yes lsb-release
DISTRIB_CODENAME=$(lsb_release --codename --short)
DEB="puppetlabs-release-${DISTRIB_CODENAME}.deb"
DEB_PROVIDES="/etc/apt/sources.list.d/puppetlabs.list" # Assume that this file's existence means we have the Puppet Labs repo added
if [ ! -e $DEB_PROVIDES ]
then
# Print statement useful for debugging, but automated runs of this will interpret any output as an error
# print "Could not find $DEB_PROVIDES - fetching and installing $DEB"
wget -q http://apt.puppetlabs.com/$DEB
sudo dpkg -i $DEB
fi
sudo apt-get update
sudo apt-get install --yes puppet
然后在Vagrantfile
中添加此行config.vm.provision :shell, :path => "upgrade_puppet.sh"
祝你好运。
答案 2 :(得分:0)
安装Puppet后,需要重新加载PATH变量。 Windows不会像Linux那样自动执行此操作。我再说一遍,它没有自动完成。它也不容易做到。
你可以强制PATH更新,我建议:
SET PATH=%PATH%;%SystemDrive%\Program Files (x86)\Puppet Labs\Puppet\bin;%SystemDrive%\Program Files\Puppet Labs\Puppet\bin;
PowerShell等效:
$env:PATH +="$env:SystemDrive\Program Files (x86)\Puppet Labs\Puppet\bin;$env:SystemDrive\Program Files\Puppet Labs\Puppet\bin;"