It would be very useful when doing maintenance on a set of multisites to have an 'all' alias.

I can't find anything existing that does this, though since 'drush sa' lists all sites in the current Drupal, the ability to do this is already partly there.

Comments

moshe weitzman’s picture

Title: add an 'all' alias » Show the @sites site alias in sa command
Assigned: Unassigned » greg.1.anderson

There is a built-in alias called @sites for this. e.g.

~/htd/fr/sites$ drush sa @sites
$aliases['.Users.mw.htd.fr#default2'] = array (
  'uri' => 'default2',
  'root' => '/Users/mw/htd/fr',
);
$aliases['.Users.mw.htd.fr#default'] = array (
  'uri' => 'default',
  'root' => '/Users/mw/htd/fr',
);

Oddly, @sites is not shown by plain old drush sa. Assigning to Greg.

joachim’s picture

StatusFileSize
new885 bytes

Here's a patch to document the @sites alias in aliases example file.

roball’s picture

Version: » 7.x-5.0

In final drush 5.0, 'drush sa' gives me

@none
@self
onesite.example.com
anothersite.example.com

where onesite.example.com and anothersite.example.com are the sites represented by the @sites alias, but the @sites alias itself is not displayed. The correct output should be

@none
@self
@sites

shouldn't it?

roball’s picture

Title: Show the @sites site alias in sa command » sa command shows actual sites representing "@sites" instead of the @sites alias
Category: feature » bug
greg.1.anderson’s picture

Title: sa command shows actual sites representing "@sites" instead of the @sites alias » Show the @sites site alias in sa command
Category: bug » feature

This is an unimplemented feature; the @sites alias has never been shown in the sa command. The old title was better.

roball’s picture

But according to

[root@server ~]# drush help sa
Print an alias record.

Examples:
 drush site-alias                          List all alias records known to drush.     
 drush site-alias @dev                     Print an alias record for the alias 'dev'. 


Arguments:
 site                                      Site specification to print 

'drush sa' should print all alias records. The @sites alias is definitely missing, but "onesite.example.com" and "anothersite.example.com" are no alias records.

What does work, however, is when the 'sa' command is executed with the '@sites' argument:

[root@server ~]# drush --component='uri' sa @sites
anothersite.example.com
onesite.example.com

The list of site URIs is printed alphabetically, which is an improvement over drush 4.

greg.1.anderson’s picture

Category: feature » bug
Status: Active » Needs review
StatusFileSize
new2.05 KB

Please try the attached patch. It should clear up both this issue, and the other one you reported in #875322: Adding context information for @sites output.

greg.1.anderson’s picture

StatusFileSize
new2.5 KB

Here is a slight improvement, for situations where there are no @sites.

roball’s picture

Status: Needs review » Active

Thank you for the quick patch. With patch #8 applied, I now get

[root@server ~]# drush sa
@none
@self
@sites
anothersite.example.com
onesite.example.com

so "@sites" is now included, fine. But shouldn't the actual @sites items (onesite.example.com, anothersite.example.com, ...) be excluded from the list of all alias records?

moshe weitzman’s picture

@roball - I think listing onsite.example.com and friends is by design.

@greg - when i use #8 patch and run dr sa from outside a drupal site, I see @sites in the list but it has no output in detail view. Is that by design? if so, feel free to commit this.

greg.1.anderson’s picture

Status: Active » Needs review

No, @sites should not show up in sa unless it contains at least one site. I thought I had already fixed that -- but in any event, I will re-fix it and then commit.

Regarding #9, yes, Drush creates an implicit alias (without an "@") for every bootstrapped or referenced site. This allows you to use the name of the site folder ("default" & c.) for rsync / sql-sync args as desired. sa lists all aliases that Drush knows about, including multiple representations of the same site.

greg.1.anderson’s picture

Status: Needs review » Needs work

Also reported: @sites is not working if $options['root'] is used to select the Drupal root.

greg.1.anderson’s picture

Title: Show the @sites site alias in sa command » Handle @sites as a first-class alias, so that it shows up in sa command and so on

Re-titling to match increased scope of patch.

roball’s picture

Version: 7.x-5.0 » 7.x-5.2

May I ask why patch #8 has not yet been committed?

greg.1.anderson’s picture

Still needs fixing per #12.

roball’s picture

Version: 7.x-5.2 » 7.x-5.7

With Drush 5.7, I now get the following error when trying to apply st to @sites:

[root@server drupal6]# drush6 -y @sites st
You are about to execute 'st' non-interactively (--yes forced) on all of the following targets:
Continue?  (y/n): y
Invalid argument supplied for foreach() backend.inc:661                                                                    [warning]
roball’s picture

Version: 7.x-5.7 » 7.x-5.9

Can we expect a fix in Drush 5.x?

Thanks for giving any status update.

greg.1.anderson’s picture

I for one am really busy right now and have no immediate plans to work on this. Patches welcome.

roball’s picture

Version: 7.x-5.9 » 8.x-6.0-rc1

The bug reported at #16 observed with drush 5.9 is still present in 6.0-rc1:

[root@server ~]# drush6 -y @sites st
You are about to execute 'st' non-interactively (--yes forced) on all of the following targets:
Continue?  (y/n): y
Invalid argument supplied for foreach() backend.inc:709                                                                    [warning]
roball’s picture

Title: Handle @sites as a first-class alias, so that it shows up in sa command and so on » Invalid argument supplied for foreach() backend.inc:709 on "drush @sites ups"
Version: 8.x-6.0-rc1 » 8.x-6.0-rc3

Actually, commands such as st or ups do work when applied on @sites, but only while being in the Drupal root directory. Being in any other directory causes drush to exit with the following error:

[root@server ~]# drush -y @sites ups
You are about to execute 'ups' non-interactively (--yes forced) on all of the following targets:
Continue?  (y/n): y
Invalid argument supplied for foreach() backend.inc:709                                                                    [warning]

So the following workaround makes it working:

[root@server ~]# cd `drush st root --format='list'`; drush -y @sites ups; cd - > /dev/null
You are about to execute 'ups' non-interactively (--yes forced) on all of the following targets:
  /usr/share/drupal7#example.com
Continue?  (y/n): y
Checking available update data ...                                                                                              [ok]
greg.1.anderson’s picture

Thanks for testing. This is a restatement of #12. Patches welcome.

greg.1.anderson’s picture

Version: 8.x-6.0-rc3 » 8.x-6.x-dev
Status: Needs work » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.