Search code examples
vagrantpuppetdirectory-structure

Is it possible to provision vagrant boxes from puppet modules located outside of the vagrant folder?


I have a production server architecture that is quite complex that involves several types and tiers of servers including: Web, Varnish, HAProxy, ELK, Database, Sensu, etc. The production architecture is provisioned with puppet masters and the puppet code for the masters is provisioned with Git through many, submodules.

I want to connect these Git repos to VM's locally to further develop pieces of the puppet architecture. However each Vagrant VM requires a complete self contained copy of all of the Git repos in order to stand up just one VM. This seems like a very inefficient use of drive space for local development on what will be potentially a dozen different types of servers.

Is there a way to point all of the Vagrant VM's VagrantFiles to a common local folder outside of the vagrant directory such that each Vagrant instance can still read the folder and provision the server?

Edited --

Based on comment from @Treminio, here is the portion of my VagrantFile showing the attempt to declare an absolute path from host computers root:

config.vm.provision "puppet" do |puppet|
  puppet.manifest_file = "init.pp"
  puppet.manifests_path = "/Users/jdugger/vm/puppet/manifests"
  puppet.module_path = "/Users/jdugger/vm/puppet/modules"
  puppet.hiera_config_path = "/Users/jdugger/vm/puppet/hieradata"
end

... and the error response by Vagrant:

==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/jdugger/vm/pupt/vagrant
    default: /vagrant_data/scripts => /Users/jdugger/scripts
    default: /tmp/vagrant-puppet/modules-169f1d27ef31a534405e2e9fcde2eedf => /Users/jdugger/vm/puppet/modules
    default: /tmp/vagrant-puppet/manifests-be5a69bfb646cf9329b8921f221ffab8 => /Users/jdugger/vm/puppet/manifests
==> default: Running provisioner: puppet...
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.

This response may not be because of the puppet path - not sure - It appears that puppet is not on the guest box (isn't it supposed to be running from Vagrant?). No version comes up when with:

[vagrant@localhost ~]$ puppet --version

Response is:

-bash: puppet: command not found

Update ---

@Treminio is correct. I have been able to provision with puppet manifests and modules external to the vagrant/ directory. The Path problem appears to be because Puppet is not installed on the guest VM. To resolve this I added a shell script found here:

http://garylarizza.com/blog/2013/02/01/repeatable-puppet-development-with-vagrant/

This was added just before the puppet provisioning declaration. Just as a note there doesn't seem to be a lot of advanced examples that demonstrate the external file capability or that you need to install puppet outside of the puppet provisioner.


Solution

  • However each Vagrant VM requires a complete self contained copy of all of the Git repos in order to stand up just one VM.

    This is incorrect.

    What you want to change is the puppet.module_path value.

    It can be any location on your host's disk, and Vagrant will automatically mount it inside your VM.