Muvix
Muvix

Reputation: 43

Vagrant+Librarian-puppet: unable to load puppet [Windows]

I am tryig to install a VM with Vagrant.

Error message:

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

Upvotes: 2

Views: 1539

Answers (3)

Erik
Erik

Reputation: 7751

I found that the scripts provided by Hashicorp handle most of my vagrant/puppet bootstrapping needs. You can find them at https://github.com/hashicorp/puppet-bootstrap

Here is an example of how I use it in a Vagrantfile that includes librarian:

# 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

Good luck!

Update:

Here is the development environment that I use: http://www.erikevenson.net/posts/2015/3/19/my-basic-development-environment

Upvotes: 2

ferventcoder
ferventcoder

Reputation: 12611

Once you install Puppet, you need to reload your PATH variable. Windows DOES NOT DO this automatically like Linux does. I repeat, it doesn't do it automatically. It also doesn't do it easily.

You can force the PATH update, which I would suggest:

SET PATH=%PATH%;%SystemDrive%\Program Files (x86)\Puppet Labs\Puppet\bin;%SystemDrive%\Program Files\Puppet Labs\Puppet\bin;

PowerShell equivalent:

$env:PATH +="$env:SystemDrive\Program Files (x86)\Puppet Labs\Puppet\bin;$env:SystemDrive\Program Files\Puppet Labs\Puppet\bin;"

Upvotes: 0

BMW
BMW

Reputation: 45343

I think this is because Ubuntu ships puppet 2.7.X which is incompatible with ruby 1.9. Specifically facter.rb doesn't appear to be in the load path for 1.9.

I ended up using and RVM install of ruby 1.8.7 with puppet as a gem. Upgrading the system puppet to 3.x probably would have worked also.

https://github.com/rodjek/librarian-puppet/issues/99
https://github.com/rodjek/librarian-puppet/pull/134
https://github.com/rodjek/librarian-puppet/pull/162

So the default puppet in Vagrant is 2.7 version, if you need latest puppet, such as 3.7.3, you need follow below url to upgrade puppet in vagrant first.

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

then add this line in Vagrantfile

config.vm.provision :shell, :path => "upgrade_puppet.sh"

Good luck.

Upvotes: 0

Related Questions