-
Get some virtual machine templates
- Precise32 works for most cases
vagrant box add precise32 http://files.vagrantup.com/precise32.box
Make a new directory wherever you want to store your virtual machine and initialize it
mkdir ~/vm
vagrant init precise32
This will give you a fresh Vagrantfile that you can configure to your needs. The main things that you will want to do is allow port forwarding and add puppet as the provisioning tools to use. Here is what the file will look like after that:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"
config.vm.provision :puppet do |puppet|
puppet.module_path = "/home/chase/.puppet/modules"
end
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network :forwarded_port, guest: 80, host: 8080
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "../data", "/vagrant_data"
end
- Now we can store all of our provisioning information in the manifests directory.
- By default, vagrant will look at the manifests/default.pp file and run everything there on creation/startup.
- Here we can define pacakges, services, files, etc...
- See attached for self-created puppet config and one that uses puppetlabs/apache as well
- If we want to use pre-built puppet modules seen here, we must create a local directory that will hold pacakges locally that will be installed to the VM.
mkdir ~/.puppet/modules
- Then we need to actually install a module. In this example we will use the very popular apache module by puppetlabs
puppet module install puppetlabs/apache
- This will install the package to our ~/.puppet/modules directory
- You can see that we specified this directory in the Vagrantfile so that it knows where these packages live
- Now we can just configure the apache, vhost, exec, php, and other relevent config items in our default.pp.