Testing Puppet Code Using The Vagrant Provisioner

Vagrant is an excellent tool used for testing out applications deployments and scripts. It is lightweight, fast, and allows you to bring up environments quickly. Vagrant supplies several “provisioners” that allow boxes to be configured via shell script or using various configuration management solutions like Puppet, Ansible and Salt.

In previous articles, I have demonstrated how to provision Vagrant boxes and configure them using shell scripting (Bash and PowerShell). This method is easy enough, but why not make use of solutions we already have in place like Puppet? This allows you to use your existing Puppet configuration code from your Puppet master and point Vagrant boxes to it for testing.


Besides having Vagrant installed on your local computer, you will also need a Puppet master in this scenario configured to serve your Puppet node. I will be using a Vagrant box configured as a Puppet Master in this example, which will be on the same private network as my Puppet node VM. If you are already using Puppet, you will want to use the Puppet master that you use for your production and development machines, so that you get the most accurate testing.

Enhance your IT career by learning how to automate with Python. Get started with this free Python guide.

Vagrant Code

There are not many options available for the Vagrant Puppet Provisioner, which is a good thing. This means less complexity! For documentation on this go here. Keep in mind by default, a Vagrant box will only run the Puppet Agent Provisioner on its first vagrant up. If you would like, you can also run vagrant up –provision parameter.

Here, I am just specifying in my Vagrant file to point my Vagrant VM to “Puppet-test”. If you would like, it can be as simple as that.

We can also specify other options such as Puppet’s binary path, client certificate path, and the name of the node. In my Vagrant file, I will just specify the Puppet master server and name of the node:

This is my Vagrant code for my node:

Read more at ipswitch.com

Leave a Reply

Your email address will not be published. Required fields are marked *