Fork Puppet(-WP)

My fellow 10upper Eric Mann recently authored a post entitled Just Ship Already in which he encouraged developers to (get this) just ship their code, already! Well, in the interest of doing just that, I’d like to announce a fork of Ryan McCue’s Puppet WordPress module.

That’s Nice. Uh, What?

Puppet is an awesome systems automation tool. Essentially, you can describe (in a Puppet DSL) the way you want a system to be configured (packages installed, processes running, etc.) and then tell Puppet “Do it” and it will, to the best of its ability, make sure that your server looks exactly like you want it. There are all sorts of useful packages of Puppet code out there (they call them “modules”) that extend the base functionality and can do a lot of the heavy lifting for you, instead of you having to develop your own Puppet code. There’s code for Apache configurations, MySQL databases, firewalls, time servers — pretty much anything that you might want to configure and/or automate on a system.

All that being said, Ryan took the initiative to create his original Puppet WP module, which is great. It essentially wraps Puppet functionality around WP-CLI and makes it so you can easily install, configure and update WordPress instances.
However, Ryan’s workflow is such that a few of WP-CLI’s sub-commands are of no real use to him, so he left a few commands out. These omissions are the primary reason for my fork. For instance, I need to be able to generate config files, automate downloads, and a few other things that scratch my own itches. Now, in order to set up a WordPress install, all you need to do is add something like the following to your Puppet manifests:

# Download WordPress
wp::download { '/vagrant/wp': }
# Create wp-config.php
wp::config { '/vagrant/wp':
    dbname => 'wordpress',
    dbuser => 'wordpress',
    dbpass => 'wordpress'
# Setup the site
wp::site {'/vagrant/wp':
    # location => '/vagrant/wp',
    url => 'http://wordpress.local',
    name => 'Test Site',
    require => Mysql::Db['store']

I won’t get into the finer details, but that looks fairly easy, doesn’t it?
If you want to grab the module and start using it in your own Puppet deployments, simply add it in your [puppet root]/modules/ directory:

git clone modules/wp

Or, if you want to add it to your project, just run:

git submodule add

I’ve tagged this initial release as version 0.5. Pull requests are welcomed. Please, download, install and automate and let me know how your experiences go.

Leave a Reply