Puppet modules are a fantastic way to deploy and manage specific applications. The Puppet Forge contains a wealth of third-party modules that allow you to do some awesome stuff with a minimum of work. In this post, we use a module from the Forge to solve a common task—using Puppet to set up a WordPress blog. Finding the best way to accomplish this with Puppet was a challenge, and helped us feel the joys and pains of those who use our software on a daily basis.

The first step is to install Puppet, Facter, and RubyGems. Since we’re using Ubuntu, we’ll use apt-get to install these packages. If you decide to use a different OS (or the Learning Puppet VM), use whatever package manager is appropriate for your platform.

Open a terminal window and type the following command: apt-get install puppet puppetmaster facter rubygems Next, install the puppet-module gem. We’ll need this in order to pull the WordPress module from the Forge and install it. gem install puppet-module Switch to your Puppet module directory. This is where you’ll run the puppet-module install command. cd /etc/puppet/modules Choosing the right module can be tricky. Usually, multiple modules are available that seem to do the same thing, but some are minimal and others are more fully featured (and sometimes a lightweight, minimal module is what you want). In our case, we needed a module that would allow us to customize the WordPress MySQL database (so user name and password could be configured without manual intervention). Unfortunately, there isn’t currently a way to determine what functionality modules expose without downloading and experimenting with them. After some trial and error, we discovered a module that worked for our purposes—and we got there by a simple search of “wordpress” at forge.puppetlabs.com. The WordPress module written by Jon Hadfield (jonhadfield/wordpress) is a good, functional module to use for setting up the blog. Switch back to your terminal window and type the following command: puppet-module install jonhadfield/wordpress Edit /etc/puppet/manifests/site.pp with your favorite editor and add the following lines, where `hostname` is output of hostname on your system and `domain.com` is the suffix for fully qualified domain names on your network: node '`hostname`.`domain.com`' { include wordpress } Up to this point, you’ve installed Puppet on your system, used puppet-module to download and extract the WordPress module, and configured your site.pp such that Puppet will manage WordPress on your system. Now, do a Puppet run to kick off the WordPress install: puppet agent --test Go to http://hostname:80 and enter the login credentials for the admin account. This will populate the WordPress database with whatever credentials you used. Okay, so, say you want to have future WordPress installations configured with this password/email combo by default. One approach is to dump your WordPress database to the template used by the WordPress module: mysqldump wordpress >> wordpress/templates/create_wordpress_db.erb You’ll need to insert one line for this to work properly, so edit create_wordpress_db.erb and insert the following line right after CREATE : USE ; Now, test this template by dropping the current database and doing another Puppet agent run. First, drop the existing database: mysql -u root -e 'drop database wordpress;' Then, do an agent run: puppet agent --test

That’s it! You’ve got a running WordPress blog!

Interaction with Puppet and its related tools should be a seamless and enjoyable experience--no matter what you’re managing or how complicated the task. We used open-source Puppet to complete this task, but you can easily do the same with our enterprise software. Get the free download at http://info.puppetlabs.com/download-pe2.html.

Learn More