Vagrant / puppet workflow

I'm new to puppet and vagrant, but I'm developing my own Puppet manifests intended to set up a vagrant box. That is, the puppet manifest is in my Vagrant directory on the host machine, and vagrant is invoking puppet -- there is no puppet server.

The thing is, my workflow is:

 while(not working as desired) {
     vagrant destroy
     amend manifest
     vagrant up
 }

... and this means quite a lot of waiting around.

What's a better way to work?


Solution 1:

Why do you keep recreating the vm? Why not ssh into it, and work on the manifest until it works?

By the way, puppet parser validate is a good way of catching primary errors before even testing what puppet is doing.

Personally, I go to a clean VM, or a VM that is a copy of whatever I want to change, copy any required modules to there under /root/modules, create a new module, and then run this:

puppet apply --modulepath /root/modules file.pp

Where file.pp includes anything necessary, and my module is inside a subdirectory of /root/modules, in the standard module configuration.

Now, there are situations where creating the vm is fundamental, such as doing the initial configuration, or validating the configuration you have so far. But I see no reason to do all the work on a newly created vm all the time.

Solution 2:

You can also re-apply manifest changes by running

vagrant provision

So your workflow becomes

vagrant up
while(not working as desired) {
 amend manifest
 vagrant provision
}

Solution 3:

I would recommend installing sahara. Then your workflow becomes:

vagrant up
vagrant sandbox on
vagrant ssh
*do some stuff that doesn't work
vagrant sandbox rollback
vagrant ssh
* do some stuff that does work
vagrant sandbox commit

I prefer rather than doing the commit you do a rollback and then add what ever you changed to your preferred provisioning scripts (puppet,chef, ssh etc)