Vagrant: Vagrant ignores the `binary_path` config when checking that Puppet is installed

Created on 24 Sep 2018  ยท  3Comments  ยท  Source: hashicorp/vagrant

When running the puppet provisioner with Vagrantfiles, the puppet plugin does not parse the binary_path option when setting the paths to check on non-Windows machines: https://github.com/hashicorp/vagrant/blob/master/plugins/provisioners/puppet/provisioner/puppet.rb#L181

This effectively renders the binary_path option useless on non-Windows machines. Oddly, the option is checked/used in the run_puppet_apply method: https://github.com/hashicorp/vagrant/blob/master/plugins/provisioners/puppet/provisioner/puppet.rb#L248

So, while there is the potential option to set a 'non-standard' puppet install location, when running this on a non-Windows machine, Vagrant throws an error:

The puppet binary appears not to be in the PATH of the guest. This
could be because the PATH is not properly setup or perhaps Puppet is not
installed on this guest. Puppet provisioning can not continue without
Puppet properly installed.

Vagrant version

Vagrant 2.0.1

Host operating system

macOS High Sierra 10.13.6 (Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64)

Guest operating system

CentOS 6.10

Vagrantfile

_Note: Puppet is actually installed via a Gemfile during the provision 'r10k_script' method call into the local directory._

Vagrant.configure('2') do |config|
  config.vm.box = 'inviqa/centos-6-minimal'
  config.vm.provider 'virtualbox' do |vb|
    cpus = Facter.value('sp_number_processors')
    if facter_mem = Facter.value('memory')
      mem = facter_mem.slice! ' GiB'.to_i * 1024
    elsif facter_mem = Facter.value('memorysize_mb')
      mem = facter_mem.to_i
    else
      raise 'Unable to determine total host RAM size'
    end

    mem = [mem / 4, 3072].max

    vb.cpus = cpus
    vb.memory = mem
    vb.customize ['modifyvm', :id, '--nestedpaging', 'on']
    vb.customize ['modifyvm', :id, '--largepages', 'on']
    vb.customize ['modifyvm', :id, '--ioapic', 'on'] if cpus > 1
  end

  config.ssh.forward_agent = true

  @r10k_script = <<~HERE
    # test if rvm is already installed, if not install it
    if ! which rvm &>/dev/null; then
      gpg --keyserver hkp://keys.gnupg.net --recv-keys \
          409B6B1796C275462A1703113804BB82D39DC0E3 \
          7D2BAF1CF37B13E2069D6956105BD0E739499BDB 2>/dev/null

      /usr/bin/curl -sSL https://get.rvm.io |
        grep -v __rvm_print_headline |
        bash -s stable 2>/dev/null
    fi

    # use the newer ruby
    # requires a subshell to source all the environment
    /bin/bash --login -c \
      '(source $HOME/.rvm/scripts/rvm &&
        rvm install 2.0.0 2>/dev/null
        rvm use ruby-2.0.0
        gem install --no-ri --no-rdoc bundler
        pushd /vagrant
        scripts/bootstrap)'
  HERE

  config.vm.define 'integration', autostart: false do |integration|
    integration.vm.hostname = hostname
    integration.vm.network 'private_network', ip: '192.168.127.127'

    integration.vm.provision 'r10k',
                             type: 'shell',
                             inline: @r10k_script,
                             privileged: false

    integration.vm.provision 'puppet' do |puppet|
      puppet.binary_path = '/vagrant/bin'
      puppet.hiera_config_path = 'hiera_testing.yaml'
      puppet.working_directory = '/vagrant'
      puppet.module_path = 'modules'
      puppet.manifest_file = 'site.pp'
    end
  end
end

Debug output

https://gist.github.com/EdgeJ/44cc1d0dddce0158c916f3b6e70a461b

Expected behavior

Vagrant should use the binary_path option to construct the Puppet path

Actual behavior

Vagrant simply searches the local $PATH of the guest machine.

Steps to reproduce

  1. Set up a method to install Puppet to a non-standard location (e.g. Gemfile installation).
  2. Add a puppet provisioning block with the binary_path set to a location with a Puppet binary, but not on the path.
  3. Run vagrant up
waiting-reply

Most helpful comment

Thanks @briancain that did work. That's what I get for perusing the source before actually upgrading versions to test something.

All 3 comments

Hi there @EdgeJ - there have been a lot of updates to the puppet provider since version 2.0.1. I recommend updating to the latest version of Vagrant (version 2.1.5) and see if that solves your issue. Thanks!

Thanks @briancain that did work. That's what I get for perusing the source before actually upgrading versions to test something.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luispabon picture luispabon  ยท  3Comments

tomhking picture tomhking  ยท  3Comments

DreadPirateShawn picture DreadPirateShawn  ยท  3Comments

jazzfog picture jazzfog  ยท  3Comments

OtezVikentiy picture OtezVikentiy  ยท  3Comments