[aegir] Using drush hosting-import to auto-create your platform node (and other entities)
Miguel Jacq
miguel.jacq at gmail.com
Tue Jan 11 17:40:35 EST 2011
Hi all,
So today I discovered a command Adrian wrote into Aegir some months
ago [1], and even told me about it, but I mustn't have been paying
attention :)
Apologies to those of you who already know about this and will laugh
at me for being such a noob.
hosting-import
==========
The command is 'hosting-import' which allows you to take an entity
represented by a Drush alias (such as a server, platform, site etc)
and have the Aegir frontend import it.
(Read that again. This will get a double-take from those of you who
are frustrated by that 'missing piece' of Aegir whereby things like
Platforms need to be created as nodes first before you can do much
with them (which means having to submit the site form, etc, etc)
The other killer feature is that you can already create 'working-copy'
builds with Drush Make by passing --working-copy as a CLI switch,
which means you retain your .git or .svn dirs etc and can get hacking.
But the problem was you couldn't get this platform into Aegir's
frontend without manually adding the platform node after you built the
platform on the filesystem.
Or, as of more recent Aegir releases, you could create the build from
scratch by giving a makefile path/URL in the platform node before you
submit the form, but then you couldn't set --working-copy, because
Drush make doesn't support putting something like [working-copy] =
TRUE in a makefile (there's a ticket and a patch about this in the
Drush make issue queue [2]), and we don't have an option to set
working-copy from the Aegir UI.
Example of adding a platform to Aegir from the command line only
================================================
# Build a platform with Drush Make. Ooh, with --working-copy!
php /var/aegir/drush/drush.php make
https://github.com/mig5/builds/raw/master/greenbee.build greenbeetest
--working-copy
# Use 'provision-save' to generate the Drush alias / context file for Aegir
php /var/aegir/drush/drush.php --root='/var/aegir/greenbeetest'
provision-save '@platform_greenbeetest' --context_type='platform'
# Use 'hosting-import' to tell the Aegir frontend to import this new
platform into the Aegir system
php /var/aegir/drush/drush.php @hostmaster hosting-import
'@platform_greenbeetest'
(node is auto-created and verify task is added to queue)
What does this mean for dev/prod workflow?
================================
It makes it more automated, and removes a somewhat flaw in my old
article [3], whereby you needed to be able to retain the .git or .svn
(etc) metadata in order to clone a live site to dev and actually hack
on it and commit your changes back.
Workflow now could look like *:
Iteration 1) totally new site
1) Build a platform with Drush Make --working copy as above
2) Save/import that platform
3) Create a site on that platform
4) hack away, commit changes back to git/svn/whatever
5) Build new 'live' platform without --working-copy
6) Clone dev site to live platform, site is now live
Iteration 2) and onwards - need to do some dev on the site
1) Build a platform with Drush Make --working-copy as above
2) Save/import that platform
3) Clone live site to a new dev site on that dev platform
4) hack away, commit changes back to git/svn/whatever
5) Build new 'live' platform without --working-copy
6) Migrate live site to new live platform, site is now upgraded
* removed the iteration/step of a 'staging' environment for client
approval, for the sake of brevity
Oh my! Look what we can do now: automated tests
=====================================
# Use provision-save to generate Drush alias /context file for a new
site on that platform
/var/aegir/drush/drush.php --uri='test.mig5.net' provision-save
'@test.mig5.net' --context_type='site'
--platform='@platform_greenbeetest' --profile='greenbee_profile'
# Install the site
/var/aegir/drush/drush.php @test.mig5.net provision-install
# Use 'hosting-task' to kick off a verify of the platform, which will
auto-import the site into Aegir
/var/aegir/drush/drush.php @hostmaster hosting-task
@platform_greenbeetest verify
(I did try and use hosting-import to import the site too, but I think
because of the way I installed the site from the backend only, it
didn't like the MySQL credentials or something, and I got errors. In
any case this older method of using the platform verify to import the
site is known to work well)
Forget about how this also solves the dev/prod workflow: better yet,
put it all in a script, and add a crontab. Hello scheduled, iterative
tests of platform build + site installs! (blog post coming...)
Feel free to copy any of those commands: greenbee.build on github is
an actual valid 'stub' makefile that more or less runs
www.greenbeedigital.com.au [4] (my consultancy) </plug> :)
Cheers!
Mig
[1] http://git.aegirproject.org/?p=hostmaster.git;a=commitdiff;h=a0bffe6d448946ff1424674c29616ac75cd10ac9
[2] http://drupal.org/node/958844
[3] http://www.migueljacq.com/content/drupal-deployments-workflows-version-control-drushmake-and-aegir
[4] http://www.greenbeedigital.com.au
More information about the aegir
mailing list