jigarius / drall

A tool to run drush commands on multi-site Drupal installations.
GNU General Public License v3.0
33 stars 5 forks source link

Use --drall-group=prod with only drush aliases files and no sites.*.php #90

Open jameswilson opened 7 months ago

jameswilson commented 7 months ago

Problem Statement

In a multisite Drupal 10 setup, when executing drall from a developer's local environment, I want a way to execute remote drush commands for all sites in a specific server environment via drush aliases *.sites.yml files.

Example Use Case

Get super user password reset links for all PROD sites.

drall --drall-group=prod exec drush uli

Expected Results

A list of password reset links for each domain grouped into the "prod" drall group via drush aliases *.sites.yml files.

Actual Results

Got error output:

In SitesFile.php line 37:

  Cannot read sites file: /var/www/html/docroot/sites/sites.prod.php

Steps to reproduce:

Proposed resolution

Before erroring out due to missing sites.GROUP_NAME.php file also scan all drush site aliases files containing drall groups defined that match the GROUP_NAME.

jameswilson commented 7 months ago

I just realized there is a workaround for my specific use case where the drall group is the same as the site alias.

drall exec drush @@site.prod st

Which begs the question, how should the drall groups in drush aliases files really be used?

jigarius commented 7 months ago

If you want to use Drush Aliases in a Drall command, then you need to specify @@site.prod. For example:

drall exec drush @@site.prod st

Now, to call that command on *.prod, you need to define the groups in each .site.yml file like you've already done. Next, use the following command:

drall exec --drall-group=prod drush @@site.prod st

If this doesn't work, please let me know.

jigarius commented 7 months ago

When you run a drall exec drush command without any Drall placeholders, Drall rewrites the command as follows:

drall exec drush --uri=@@dir st

The @@dir then takes the value of each item in $sites, e.g. array_values($sites). In order to use Drush aliases, you must specify @@site.prod in your command.

Furthermore, please consider checking out the --drall-filter parameter which might give you some more flexibility in choosing target sites.