Drupal is an amazing tool for quickly constructing attractive, functional web sites. It lets you manage large numbers of web sites from a single installation, and (via add-on modules) provides almost any CMS or blog feature you could want.

However, like any powerful tool, Drupal takes some learning. It also needs a certain amount of discipline to manage Drupal servers without getting into a chaotic mess. The Drupal sysadmin can end up trying to navigate a spaghetti of ad-hoc symlinks and face problems upgrading, maintaining, monitoring and backing up a large Drupal installation.

The primary tool for automating Drupal management is Drush – a command-line utility which can download and update modules, themes and core code, access the database, and many other useful functions. Here is an example recipe using Drush to manage modules:

define module() {
  exec { "install-module-$name":
    cwd => "/var/www/drupal/sites/all/modules",
    command => "/usr/local/bin/drush dl $name",
    creates => "/var/www/drupal/sites/all/modules/$name",
  }
}

class drupal::modules {
  drupal::module { [ "admin_menu",
                     "cck",
                     "comment_notify",
                     "contact_forms",
                     "filefield",
                     "google_analytics",
                     "imagecache",
                     "nodewords",
                     "views",
                     "views_attach",
                     "views_bulk_operations",
                     "weblinks" ]: }
}

You can find more about using Drush and Puppet to automate Drupal, plus a complete set of recipes for managing Drupal sites, here: Puppet Drupal recipes.