29

Question

Can anyone explain why it would be better to choose the puppet or chef vagrant provisioners, rather than the shell provisioner?

Background

I'm in the process of getting started with Vagrant. One of the things I'm having trouble with is deciding which provisioner to use. So far, I've had some success using the shell provisioner, but it has been more work than I expected to get it to run reliably.

At the moment, I'm not familar with ruby, puppet or chef, but I'm happy to learn any or all of them if I have to. My early experience playing with puppet and chef is that if someone else has a recipe that does exactly what you want, it works really well, but doing something non-standard means falling back coding up solution in ruby.

I'm aware of articles comparing puppet and chef, and I'm less worried about which of them to use, rather than knowing when and why I should use them at all.

3 Answers 3

27
+50

Full disclosure: I'm a Puppet Labs employee. But I chose Puppet as a product over 2 years before joining them.

I would recommend that you use Puppet or Chef over shell if your configurations are going to a) have any degree of complexity and b) going to change over time - or you expect your installation environment itself to change in a way that might alter the way your deployment performs. Your scripts may be very good, but ultimately, unless you are following terrific programming practices around them, testing and QA'ing them, etc they are going to fail at some point.

There's an entire body of literate around DevOps discussing this notion, but it comes down to the principle of "technical debt" - we tend to do things the easy way now, and thus perceive them as simpler, at the cost of increasing complexity and difficulty later.

One of Puppet's strengths is its deterministic nature - the manifest you write must be able to be programmatically transformed by Puppet into a model of the server you are building. This is perceived by people as being more "difficult" but I would argue that the difficulty is lessened if you average it out along the curve of your technology's lifecycle. In other words, Puppet forces you to do your thinking now, but then deploy to scale with ease, rather than thinking later and re-engineering as you go. Pay in cash now, rather than by credit, with interest, later.

If you're purely pulling down other peoples' manifests, you're going to run into trouble at some point - although we would like it not to be so, working with Puppet today that's certainly the case, because they are writing them to address the general case, and not your particular system. Many general-purpose manifests become useful only when you reach a better understanding of Puppet.

So rather than start there, I'd work my way through the excellent Learning Puppet guide to start to grasp the basics. Puppet's learning curve is steep, but it levels off after a short while.

There are other reasons to use other provisioners or tools, but I'd surely argue that you are better with Puppet or Chef than trying to ensure that your shell scripts are doing exactly what you think they are supposed to do, for as long as you need to spawn new environments.

5
  • thanks for this answer. Would you mind commenting on the differences in effort required for QA'ing shell and puppet. This is a big source of my reservations in making the change at the moment. Oct 21, 2011 at 5:24
  • 2
    There are frameworks and harnesses for both. You can look at rspec-puppet or cucumber-puppet for some useful TDD/BDD Puppet tools. There are test harnesses for shell too, but the problem with shell is that you have to handle all of your own failure cases - how do you know that you've succeeded, and how do you know that your code is doing what you assert it does? Puppet contains a lot of the framework for handling that stuff, and so makes troubleshooting/verifying code a simpler exercise.
    – eshamow
    Oct 21, 2011 at 17:54
  • 6
    +1 for great "Pay in cash now, rather than by credit, with interest, later." technical debt allegory. Aug 1, 2012 at 14:25
  • 3
    I think shell provisioners are great, provided you think of them as prototypes, and replace them with Chef or Puppet before the interest comes due. It's easier to get something working with shell scripts, and if you're still figuring out exactly what you need, then this prototype phase will really help a lot. The problem is if your management thinks you're done when the shell scripts work, and won't let you replace them. Then you're going to be building up lots of interest, and by the time you're allowed to pay cash you might just break the bank.
    – iconoclast
    Sep 12, 2012 at 19:18
  • 1
    Actually, in the context of Vagrant, you may never have nearly the complexity that Chef and Puppet were designed to handle. If your case is simple enough, then shell scripts might be fine forever. It's really when you have a more complex setup that Chef and Puppet pay for themselves.
    – iconoclast
    Sep 12, 2012 at 19:20
10

Ah, with the freedom of choice comes the complication of choosing what is right for you.

Chef Solo - Chef solo is most ideal if you’re just getting started with chef or a chef server is simply too heavy for your situation. Chef solo allows you to embed all your cookbooks within your project as well, which is nice for projects which want to keep track of their cookbooks within the same repository. Chef solo runs standalone – it requires no chef server or any other server to talk to; it simply runs by itself on the VM.

Chef Server - Chef server is useful for companies or individuals which manage many projects, since it allows you to share cookbooks across multiple projects. The cookbooks themselves are stored on the server, and the client downloads the cookbooks upon running.

Puppet - The Puppet provisioner runs stand-alone Puppet manifests that are stored on the server and downloaded to the client VM when it is created. The provisioner does not require a Puppet server and runs on the VM itself.

Puppet Server - The Puppet Server provisioner connects to a Puppet server and configures your client VM using node configuration on that server.

Other tools, shell scripts, etc. - Do you use something other than that which is built into Vagrant? Provisioners are simply subclasses of Vagrant::Provisioners::Base, meaning you can easily build your own, should the need arise.

You can also check out the documentation, docs.vagrantup.com/v2

2
  • +1, this makes sense, but I was really hoping for slightly more practical advice. I'll see if I can edit the question to make this clearer Oct 20, 2011 at 5:53
  • Looks like the link is dead.
    – mpoisot
    Jul 24, 2014 at 21:08
4

I would choose the Shell provisioner, then let the shell script clone your puppet/chef repository from github or bitbucket. The script can setup a ssh key to allow automated git clone. The benefits are most cloud providers support this as well so you can use the same script.This blog is explains git, puppet and vagrant well, one man and the cloud blog

1
  • I have fixed it, the domain name expired.
    – Mark
    Jul 29, 2013 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.