Using the puppet provisioner with vagrant

May 7, 2014   #puppet  #vagrant 

I needed to setup a quick dev environment using debian wheezy with mongodb. Vagrant is my go to for testing things out with mucking up my laptop. The first step was go get a vagrant box with wheezy. Puppetlabs has a nice collection of boxes available. An easy to use puppet module for mongodb is available from the module forge.

mkdir vagrant_mongo
cd vagrant_mongo
# Create Vagrantfile
vagrant init debian-73-x64-virtualbox-puppet http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-puppet.box
# Install the mongo module
puppet module install --modulepath puppet/modules puppetlabs-mongodb
# Create directory for puppet manifests
mkdir -p puppet/manifests

Edit the Vagrantfile to enable provisioning via puppet.

config.vm.provision "puppet" do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path = "puppet/modules"
    puppet.manifest_file  = "site.pp"
end
# If you want the mongodb that is running in the guest available from your host
config.vm.network "forwarded_port", guest: 27017, host: 27017

Create puppet/manifests/site.pp and invoke mongodb module.

class { "::mongodb::globals":
  manage_package_repo => true
}
class { "::mongodb::server":
  bind_ip => ['0.0.0.0']
}

At this point vagrant is ready to start.

vagrant up
vagrant ssh