Automating Drupal Deployment With Drush Make a-1
-
Upload
jazzslider -
Category
Documents
-
view
232 -
download
0
Transcript of Automating Drupal Deployment With Drush Make a-1
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
1/44
Automating Drupaldeployment with
drush_make, installation
profiles and featuresDrupalCamp Austin 2009Presented by:
Adrian Rollett & Adam JensenCentral Web Support
University of North TexasTwitter: @acrollet @jazzslider
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
2/44
Who are we, anyway?
UNT Central Web Support office handles:o Systems administrationo Web application developmento
Hosting services UNT recently selected Drupal as the officialcampus CMS
Have rolled out 300 instances of our
custom Drupal distribution
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
3/44
What's in it for me?
Image by flickr user atlanticlost
http://www.flickr.com/photos/atlanticlost/1514571779/http://www.flickr.com/photos/atlanticlost/1514571779/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
4/44
Dynamic web apps without Drupal
Functionality lives in code Content lives in the database
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
5/44
Dynamic web apps with Drupal
Functionality lives mostlyin code, but whatabouto Content types?o
Views?o Dependencies?
How do youo Use version control?
o Package it up for redistribution?o Deploy it elsewhere?
One common solution: put database dumpsin version control!
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
6/44
Versioning database dumps is kindof like making a photocopy of a
pig: messy, difficult and time-consuming
Original photos by flickr users sugarmtnfarm andbinglib
http://www.flickr.com/photos/sugarmtnfarm/73613859/http://www.flickr.com/photos/binglib/2343354824/http://www.flickr.com/photos/binglib/2343354824/http://www.flickr.com/photos/sugarmtnfarm/73613859/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
7/44
So what then?
Functionality should still live in code ifpossible, but why?
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
8/44
Less Clicking: make your changesin code, not with a mouse
Image from warmouse.com
http://warmouse.com/http://warmouse.com/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
9/44
Easy automation of deployment
Original image by flickr user jasoneppink
http://www.flickr.com/photos/jasoneppink/499644215/http://www.flickr.com/photos/jasoneppink/499644215/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
10/44
Features
The Features module (currently beta3) allows you toexport sets of functionality (photo albums, blogs,calendars, etc.) as "features"
Features are modules, but at a higher level of
abstraction Key differences:
o Code is generated, (usually) not written by hando Collects functionality rather than creating ito Easily enabled by lay people, and they don't have
to look at the core modules page to do it
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
11/44
What is a feature?
Features bringtogether all thelittle pieces that
make up usable,fully-configuredDrupalfunctionality.
Image from XKCD: http://xkcd.com/659/
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
12/44
What are the pieces?
Information about module dependencies Exported configurations for things like
o content types,o
views,o menu items, ando pretty much anything else that
can be exported as code, and
has a machine-readable name. Most importantly: features are modules,
so all these pieces are defined in code.No database dumps to manage.
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
13/44
For example
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
14/44
Making an event calendar the oldway
1. Download calendar, cck, date, and views;enable several relevant modules from eachproject.
2. Create an "Event" content type.3. Assign a date field to the Event content type.4. Clone the calendar view that comes with the
calendar module.5. Modify the view such that it only shows Event
nodes, and places them on the calendar usingtheir date field.
6. Go back over the end result to make sure youdidn't miss a step. All told, 15 minutes. Not
too bad, but
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
15/44
Making an event calendar withfeatures
1. Do all that other stuffonce.
2. Create a new feature,making sure to
specifyoThe module
dependenciesoThe content type to
exportoThe view to export Initial setup, 20
minutes. But then
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
16/44
Deploying a feature
Once you've built yourfeature, deploying toanother site is simple:1. Install the feature
code as you wouldany other module
2. Make sure that thedependent modulesare there
3. Visitadmin/build/featuresand enable it!
Time spent: 5 minutes,
maybe less.
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
17/44
Some advantages
As long as the moduledependencies are there,you can now install thissame feature on any site invirtually no time.
Since everything is in code,it'so versionable,o packageable, ando deployable.
End users can turn it on andoff without worrying aboutthe nitty gritty configurationdetails.
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
18/44
What it doesn't do
Some common needs thatfeatures can't handle yeton its own:o Exporting taxonomy
vocabularies.Exportables module
can help with thiso Exporting variables.o Enabling blocks.o Exporting nodes (not
really within scope).o Probably more things.
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
19/44
How to deal with that
Features are modules. If necessary, youcan add your own hook_enable() andhook_disable() code to ensure that
everything is set up as it needs to be. Avoid changing any of themodule.features.*.inc files. These can beoverridden if you later re-export your
feature, so stick to editing the .module and.info files.
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
20/44
Features servers
Rather than uploading features modules todrupal.org, you can set up your own serverusing the feature server moduleo
http://code.developmentseed.org/featureserver/d Decentralized approach to distribution
means you can have greater control over
the process Seehttp://developmentseed.org/blog/2009/jun/24/drupal for more information
http://code.developmentseed.org/featureserver/dashboardhttp://code.developmentseed.org/featureserver/dashboardhttp://developmentseed.org/blog/2009/jun/24/distributed-feature-servers-drupalhttp://developmentseed.org/blog/2009/jun/24/distributed-feature-servers-drupalhttp://developmentseed.org/blog/2009/jun/24/distributed-feature-servers-drupalhttp://developmentseed.org/blog/2009/jun/24/distributed-feature-servers-drupalhttp://code.developmentseed.org/featureserver/dashboardhttp://code.developmentseed.org/featureserver/dashboard -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
21/44
What's next?
Features is great for discrete functionality,but what if you could do the same thing foryour entire site?
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
22/44
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
23/44
What is drush_make?
From drupal.org/project/drush_make:
Provides the equivalent of a make script for
Drupal, using Drush.
http://drupal.org/project/drush_make/http://drupal.org/project/drushhttp://drupal.org/project/drushhttp://drupal.org/project/drush_make/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
24/44
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
25/44
From the readme file:
Drush_make is an extension to drush thatcan create a ready-to-use drupal site, pullingsources from various locations.o
It does this by parsing a flat text file(similar to a drupal .info file) anddownloading the sources it describes.
In practical terms, this means that it is
possible to distribute a complicated Drupaldistribution (such as Development Seed'sManaging News) as a single text file.
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
26/44
What can drush_make do?
Download Drupal core, as well as contribmodules from drupal.org.
Fetch themes and installation profiles.
Check code out from CVS, SVN, git and bzrrepositories. Download plain .tar.(gz) and .zip files
(particularly useful for libraries that can not
be distributed directly with drupal core ormodules). Fetch and apply patches.
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
27/44
What does a makefile look like?
It can be as simple as this:
$ sudo cat distro.buildcore = 6.x
projects[] = drupalprojects[cws_d6][type] = "profile"projects[cws_d6][download][type] = "svn"projects[cws_d6][download][url] ="file:///export/web/svn/drupal_install_profiles/trun
k/cws_d6"projects[cws_d6][download][branch] = "trunk"
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
28/44
$ drush make distro.build newProject information for drupal retrieved.drupal downloaded fromhttp://ftp.drupal.org/files/projects/drupal-6.14.tar.gz.cws_d6 downloaded fromfile:///export/web/svn/drupal_install_profiles/trunk/cws_d6.Project information for admin_menu retrieved.
Project information for cck retrieved.Project information for cws_event_calendar retrieved.adminrole downloadedfrom http://ftp.drupal.org/files/projects/adminrole-6.x-1.1.tar.gz.adminrole patched with adminrole_exceptions.patch.cws_event_calendar downloaded from https://cws.unt.edu/[...]/cws_event_calendar-6.x-1.0-beta4.tar.northtexas downloaded fromfile:///export/web/svn/cws/northtexas_theme.tinymce downloaded from http://downloads.sourceforge.net/[...]/tinymce_3_2_7.zip.
Here it is in action (truncated output):
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
29/44
Wait a minute, how diddrush_make know to grab all those
other items? If the installationprofile you specifyincludes a make file,
drush_make willautomatically parseit.
That's the beauty ofrecursion!
Original photo by flickr userfrangipani_photograph
http://www.flickr.com/photos/frangipani_photograph/3066995907/http://www.flickr.com/photos/frangipani_photograph/3066995907/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
30/44
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
31/44
Can't I do the same stuff with ashell script?
Yes, but there are several advantages:o A drush_make make file is simply descriptive;
tell it what dependencies your site needs, and ithandles the process of retrieving them
o Make files are sharable, distributable, andguaranteed to work on any system that runsDrupal
o Make files also tend to be more succinct and
human-readable than shell scripts (no need toknow bash/python/ruby/etc.)o It's a standard, public, open source tool instead
of a custom solution
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
32/44
Custom Drupal to Go: tying it alltogether with installation profiles
Original photo by flickr userdsnet
http://www.flickr.com/photos/dsnet/146971384/http://www.flickr.com/photos/dsnet/146971384/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
33/44
If features provide all neededfunctionality, what use are
installation profiles?
Original photos by flickr users albaum andtexasrobo
http://www.flickr.com/photos/albaum/449085555/http://www.flickr.com/photos/texasrobo/698785375/http://www.flickr.com/photos/texasrobo/698785375/http://www.flickr.com/photos/albaum/449085555/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
34/44
Installation profiles are the gluebetween drush_make and features
Installation
profiles
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
35/44
drush_make + features will giveyou this out of the box:
FAIL
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
36/44
What you see after logging in toan Open Atrium site for the first
time
http://openatrium.com/http://openatrium.com/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
37/44
Wait, aren't installation profilesbad???
The main problem holding back the full potential ofinstallation profiles is the lack of a packaging tool forcontributed modules.
-- Greg Knaddison (greggles)
Installation profiles have had a bad rapfor some amount of time. Probably thechief complaint is the following:
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
38/44
drush_make solves that problem!
Original image by flickr userdbgg1979
http://www.flickr.com/photos/dbgg1979/3595224548/http://www.flickr.com/photos/dbgg1979/3595224548/ -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
39/44
Other drawbacks of installationprofiles
You must know PHP and the Drupal APIso If you're a developer, hopefully this
doesn't scare you!o
the installation_profile_api module helpssomewhatThey can be somewhat finicky to buildThey can only be run at install time.
o
anything you want to be able to enableand disable should be contained in afeature (or module update)
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
40/44
What are installation profiles goodfor in the context of this
presentation? Enabling a custom theme Doing one-time setup tasks like
o enable modules and featureso download and install translationso disable unnecessary default functionality
Anything! *
* (perhaps notanything)
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
41/44
Tips for building InstallationProfiles
Start with the default profile, and modify itto your purposes
The open atrium installation profile is a nice
example Always look for an install_profile_api helperfunction first
The name of your profile and the directory
it's in should be the same When debugging an install profile, you'llwant php debug output to be on
Clear *all* caches at the end of your profile
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
42/44
References
http://drupal.org/project/featureso http://drupal.org/project/exportableso http://code.developmentseed.org/featureserver/daso http://developmentseed.org/blog/2009/jun/24/distrib
drush_makeo drush_make READMEo blog post from mig5.net on drush_make and aegiro proposed patch for generating makefiles
Installation Profileso Damien McKenna's very helpful post on building inst
http://drupal.org/project/featureshttp://drupal.org/project/exportableshttp://code.developmentseed.org/featureserver/dashboardhttp://developmentseed.org/blog/2009/jun/24/distributed-feature-servers-drupalhttp://drupal.org/project/drush_makehttp://drupalcode.org/viewvc/drupal/contributions/modules/drush_make/README.txt?revision=1.1.2.2&view=markup&pathrev=DRUPAL-6--2http://www.mig5.net/content/drupal-deployments-workflows-version-control-drushmake-and-aegirhttp://drupal.org/node/567000http://www.mc-kenna.com/drupal/2009/06/building-drupal-installation-profileshttp://www.mc-kenna.com/drupal/2009/06/building-drupal-installation-profileshttp://drupal.org/node/567000http://www.mig5.net/content/drupal-deployments-workflows-version-control-drushmake-and-aegirhttp://drupalcode.org/viewvc/drupal/contributions/modules/drush_make/README.txt?revision=1.1.2.2&view=markup&pathrev=DRUPAL-6--2http://drupal.org/project/drush_makehttp://developmentseed.org/blog/2009/jun/24/distributed-feature-servers-drupalhttp://code.developmentseed.org/featureserver/dashboardhttp://drupal.org/project/exportableshttp://drupal.org/project/features -
8/14/2019 Automating Drupal Deployment With Drush Make a-1
43/44
Questions?
-
8/14/2019 Automating Drupal Deployment With Drush Make a-1
44/44
Thank you!
Adam Jensen@jazzslider
Adrian Rollett@acrollet
UNT Central Web Support
https://webadmin.unt.edu