User login

Settings for sets of sites: Putting Drush configuration into your project repository

Inherit local-only options with 'parent'

Parent is not working across files. Filed support request: http://drupal.org/node/1262230

In an aliases file that lives with your project, so for our SDL project, sdl.aliases.drushrc.php, put in all settings that are true no matter who is using Drush and from where. This is the settings for an externally hosted development collaboration site.

<?php
$aliases
['dev'] = array(
 
'parent' => '@testserver',
 
'remote-host' => 'simone.mayfirst.org',
 
'root' => '/var/local/drupal/sdl/web',
 
'uri' => 'sdl.agariclabs.org',
);
?>

Note the 'parent' => '@testserver' line. If there's no alias named @testserver Drush doesn't cry about it.

Then in a local file:

<?php
/**
 * @file
 * Drush aliases that are shared for most sites, such as base configuration.
 */
$aliases['testserver'] = array(
 
'remote-user' => 'fred',
);
$aliases['local'] = array(
 
'root' => '/home/ben/code/sdl/web',
 
'uri' => 'sdl.localhost',
);
?>

Gotcha: The alias path is to the folder containing the aliases file, not directly to the alias file itself

If you are in the same directory as the aliases file you want to use:

WRONG: drush @dev status --alias-path=sdl.aliases.drushrc.php
RIGHT: drush @dev status --alias-path=.

I spent over an hour trying to figure out wasn't working here. Watch me suffer.

To check the status of all your aliased sites (including the local Drush version they are using), you can use, where anjali is the name of a project used in the filename anjali.aliases.drushrc.php:

drush @anjali status

(You can run any Drush command on all sites at once but i cannot think of many commands for which that is even remotely, pun intended, a good idea.)

Using a relative path to an alias

Attempting to use a relative path .. or ../ does not work- no, correction, the relative path does not work if it is combined with another path with the colon.

The absolute path alone works:

<?php
/**
 * @file
 * Drush configuration.
 */

/**
 * Additional directories to search for *.alias, *.aliases.drushrc.php files.
 *
 * Follows the form:
 * $options['alias-path'] = '/path/to/aliases:/path2/to/more/aliases';
 */

$options['alias-path'] = '/home/ben/code/sdl';
?>

This also works:

<?php
$options
['alias-path'] = '..';
?>

But either of these do not work:

<?php
$options
['alias-path'] = '..:/home/ben/code/sdl';
$options['alias-path'] = '/home/ben/code/sdl:..';
?>

Note: I don't know that there is any reason not to put mysite.drushrc.php right in the Drupal root (or the aliases file in the sites/ directory). Aside from vague security concerns, this method seems just fine. Personally i prefer not to have anything in the web root that does not naturally belong there, and am willing to jump through a few hoops to put it elsewhere. In consideration of the rest of my team, however,

Reference

Sources of information for this how-to include the command drush topic core-global-options, but primarily the excellent help text in drush/examples/example.drushrc.php and drush/examples/example.aliases.drushrc.php.

Searched words: 
tell drush to always look for aliases file in directory above root sites' aliases

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.