Skip to content

Instantly share code, notes, and snippets.

@luxflux
Last active August 29, 2015 14:02
Show Gist options
  • Save luxflux/26ba2a10947512d8cd6b to your computer and use it in GitHub Desktop.
Save luxflux/26ba2a10947512d8cd6b to your computer and use it in GitHub Desktop.

Managing a few servers with Puppet

In this blog post I'm going to show you how I manage a few servers centrally using Puppet without a Puppet Master.

Puppet is an open source configuration management software. It allows you to manage many thousand servers centrally and install packages on them for example. Check out their website for more information. There are also other tools similar to Puppet, like Chef or Ansible.

The Problem

I run a few virtual servers for personal use (e.g. for backup, file syncing, and some web-based tools). Managing them by hand can be tedious.

Imagine you want to change the configuration of your SSH service on all hosts, or you want to move a server to another provider. You'd have to do everything manually. And if you didn't document every step in the first place, you'll lose plenty of time too (unless you have a very good memory ;) ).

Having a central place to manage the whole setup and configuration of your servers solves these problems. Changes to all servers can be easily applied. Need to move a server? Just fire it up and let the tool do the rest.

And on top of that, every server is automatically documented.

Enter Puppet

As I have already mentioned, Puppet is an open source configuration management tool. Many large companies use it to manage their infrastructure.

Puppet can be run in different modes:

  • Client/Server: This mode involves a central PuppetMaster server. The servers (clients) fetch their configuration from the master.

  • Standalone: In standalone mode, Puppet is run directly on a server using the puppet executable.

If you only have a few servers, you obviously don't want to run a PuppetMaster server. The standalone mode looks like a good fit. But having to log in into every server, download the configuration, and run Puppet doesn't seem to be a nice solution.

There must be something better.

Solution

Based on the standalone mode, I started looking for a solution running locally on my computer. It should connect to the servers, copy the configuration, and run Puppet. Having used Chef before, I knew knife-solo which works like this.

I finally stumbled upon supply_drop. It's a Ruby Gem based on Capistrano and defines some tasks to run Puppet on servers. Bingo!

Because the file structure of supply_drop didn't fit my needs, I built a simple solution on top of it.

It works like this:

# Bootstrap new server crafted.ch (install Puppet on it etc.)
cap puppet:bootstrap:puppetlabs:ubuntu

# Run Puppet on server crafted.ch
cap crafted.ch puppet:apply

# Test configuration for server crafted.ch in a local Vagrant VM
cap crafted.ch-test puppet:apply

You can find my solution on GitHub. Simply clone it and follow the instructions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment