Skip to content

Puppetry for Drupaleros

Jonathan Araña Cruz edited this page Jul 18, 2015 · 4 revisions

Instructions to install several versions of Drush system-wide based on jonhattan/drush Puppet module.

This instructions are a quick walkthrough indicated for people that don't have the time or the need to learn Puppet.

All instructions below are intended to be run as root user.

Install Puppet

First we need to install Puppet. Packages provided by distros are outdated, but Puppet folks provide their own repositories. Here're quick steps for Debian and RedHat families (including Ubuntu and CentOS). You can find more information at PuppetLabs Install Guide.

Debian family

Choose your release and proceed with the following instructions.

RELEASE=jessie # Change to squeeze, lucid, precise, trusty ...
wget https://apt.puppetlabs.com/puppetlabs-release-$RELEASE.deb
dpkg -i puppetlabs-release-$RELEASE.deb
apt-get update
apt-get install puppet

RedHat family

Choose your release and proceed with the following instructions.

RELEASE=el-7 # Change to el-5, el-7, fedora-19, fedora-20...
rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-$RELEASE.noarch.rpm
yum install puppet

Install Puppet modules

Once Puppet is installed, we need to download PHP and Drush modules. PHP module is responsible of installing Composer.

puppet module install mayflower/php
puppet module install jonhattan/drush

Install Drush

The most basic thing is to just instruct Puppet to include the classes (puppet apply -e "include [php, drush]"), but is has the undesired side effect of installing php5-fpm package because of Mayflower/php module defaults.

So we need a Puppet manifest to tweak the module defaults and eventually provide it with extra configuration. Here's how a manifest looks like:

class { 'php':
  manage_repos => false,
  fpm          => false,
  dev          => false,
  pear         => false,
}
class { 'drush':
  require               => Class['php'],
  versions              => ['7', 'master'],
  default_version       => 'master',
  autoupdate            => true,
  ensure_extra_packages => true,
  extensions            => ['drush_extras', 'registry_rebuild', 'settingsphp'],
}

drush::alias { 'foo':
  root => '/var/www/foo/htdocs',
  uri  => 'foo.local',
}

drush::alias { 'bar':
  root => '/var/www/bar/htdocs',
  uri  => 'bar.local',
}

See manifests/init.pp and manifests/alias.pp for more detail on options accepted by drush class and the aliases definitions.

To proceed, copy the manifest code to a file, tweak it to your needs and once you're done, save it to drush.pp (or whatever) and run puppet apply drush.pp.

Once Puppet finishes, you can find the Drush versions you choose installed at /opt/drush. For each version, a symlink is created at /usr/local/bin.

When new releases of Drush are available, just run puppet apply drush.pp to keep up to date.