Skip navigation.

Puppet and MySQL: create databases and users

MySQL module for Puppet

Puppet MySQL management couldn’t be easier. Most applications use some kind of SQL database, and MySQL is a simple, easy to use, drop-in solution. In this article I’ll show you how to manage your MySQL servers, users, databases, and access permissions using Puppet. Read more »

Get your life back: 12 steps to taking control of email

1. Admit you have a problem. “The mass of men,” wrote Thoreau, “lead lives of quiet desperation,” and he didn’t even have email. We’re drowning under the stuff. Sysadmins get a lot of email, and when you’re spending more time on your inbox than at the command line, there’s a problem.

When Outlook helpfully notified me one morning that I had 40,000 email messages in my inbox, I had a moment of clarity. I knew I needed to go on an email detox. But how? Read more »

10 awesome sysadmins and devops

It’s Sysadmin Appreciation Day, so here is my personal list of the most interesting and influential sysadmins and devops folk that I know (in alphabetical order, not order of merit). If you are on Twitter, you need to be following these people, and all of them are also excellent bloggers as well as awesome sysops / devministrators / tech gods. Read more »

Sysadmin iPhone apps - the portable toolbox

Have you ever needed to SSH to a server from the pub? I have. Sysadmins and devops are widely expected to be ‘always-on’, and until recently that meant carrying a laptop or netbook around with you. However, the iPhone is a powerful pocket sysadmin tool. We look at the ten essential iPhone sysadmin apps that should be available on your hip at all times. Read more »

Puppet Tutorial for Linux part 2: Client and Server

Puppet tutorial series

In Part 1 of this Puppet tutorial we saw how to install Puppet on a Linux machine from source, and create a basic manifest which controls the NTP service. In this episode we’ll cover setting up a Puppet server and then using it to control multiple client machines.

Installing servers with Puppet

In the first part of the tutorial, we installed Puppet directly from the source. This is a great way to learn and experiment, but for production purposes we would like to use a standard package - in this case, an Ubuntu package we can install via apt-get. This way, you can ensure that the same version of Puppet is present on your servers and update it automatically if need be. The Ubuntu package also has a few bonus features that the source package doesn’t.

If you want to follow along with the tutorial using your existing Puppet source install, that’s fine. It’s a good idea to make sure you’re using the same version of Puppet on both client and server, or you may run into obscure and annoying problems, so either install from the same source package on your client machine, or set up two fresh machines with the Ubuntu package as described below.

The version of Puppet in the standard Ubuntu repositories is a little old, so add Mathias Gug’s puppet-backports repository to your machine so that you can get a more recent version:

# add-apt-repository ppa:mathiaz/puppet-backports
# apt-get update
# apt-get install puppet puppetmaster

You can now start the Puppetmaster daemon and make the service persistent:

# update-rc.d puppetmaster defaults
# puppet master --mkusers

If there is a firewall between the Puppetmaster and its clients (eg an iptables firewall on the Puppetmaster server itself) you will need to open TCP port 8140 to the clients.

Create a client manifest

In Part 1 of the Puppet Tutorial we created a file /etc/puppet/manifests/nodes.pp, which lists the nodes (machines) that Puppet knows about, and what configuration they should have. Currently it looks like this:

node myserver {
    include ntp

As we’re adding a new node to the system, we need to modify the file so that it reads like this:

node myserver {
    include ntp

node myclient {
    include ntp

Authorising a client

Puppet uses SSL (Secure Sockets Layer), an encrypted protocol, to communicate between master and clients. This means that only a client with a correctly signed SSL certificate can access the Puppetmaster and receive its configuration. To exchange certificates between the master and client, follow this procedure.

Configuring the client to contact the server

Edit your /etc/puppet/puppet.conf file to tell the client where to find the Puppetmaster:

server =

Generate a certificate request

On the client, run:

# puppet agent --test
info: Creating a new certificate request for
info: Creating a new SSL key at /etc/puppet/ssl/private_keys/
warning: peer certificate won't be verified in this SSL session
notice: Did not receive certificate
notice: Set to run 'one time'; exiting with no certificate

Sign the certificate

On the master:

# puppetca -l

There is a certificate request pending for myclient. To sign it, run:

# puppetca -s
notice: Signed certificate request for
notice: Removing file Puppet::SSL::CertificateRequest at 

If there is no certificate request listed, the client was not able to contact the server for some reason. Check that you have the right server address set in puppet.conf on the client, and that TCP port 8140 is open on both the master and client firewalls. The puppet master daemon also needs to be running on the master.

Run Puppet for the first time

On the client, you should now be able to run:

# puppet agent --test
notice: Got signed certificate
info: Caching catalog at /var/puppet/state/localconfig.yaml
notice: Starting catalog run
notice: //ntp/Service[ntp]/ensure: ensure changed 'stopped' to 'running'
notice: Finished catalog run in 0.92 seconds

Just as on the server in the first part of the tutorial, Puppet is now applying the ntp class to myclient. At the moment all this class does is ensure the ntp service is running, but of course it could do many more interesting things. And that’s what we’ll look at next time in Part 3.

Puppet books

If you’re excited about Puppet and want to learn more, may I modestly recommend the Puppet 2.7 Cookbook? The Puppet 2.7 Cookbook takes you beyond the basics to explore the full power of Puppet, showing you in detail how to tackle a variety of real-world problems and applications. At every step it shows you exactly what commands you need to type, and includes full code samples for every recipe.

Syndicate content