Drall
Drall is a tool to that helps run drush commands on multi-site Drupal installations.
One command to drush them all. — Jigarius
A big thanks and shout-out to Symetris for sponsoring the initial development of Drall.
Installation
Drall is listed on Packagist.org. Thus, it can easily be installed using composer
as follows:
composer require jigarius/drall
Commands
To see a list of commands offered by Drall, run drall list
. If you feel lost, run drall help
or continue reading this documentation.
exec
There are a number of ways to run drush
commands on multiple sites.
With @@uri
In this method, the --uri
option is sent to drush
.
drall exec --uri=@@uri core:status
Or simplify omit the --uri=@@uri
and it will be added automatically.
drall exec core:status
Example
$ drall core:status
drush --uri=default core:status
drush --uri=donnie core:status
drush --uri=leo core:status
drush --uri=mikey core:status
drush --uri=ralph core:status
Here, the --uri
is populated with names of the subdirectories under sites
in which the various sites live.
With @@site
In this method, a site alias is sent to drush
.
drall exec @@site.local core:status
Example
$ drall exec @@site.local core:status
drush @tmnt.local core:status
drush @donnie.local core:status
drush @leo.local core:status
drush @mikey.local core:status
drush @ralph.local core:status
Here, @@site
is replaced with site names detected from various site alias definitions.
site:directories
Get a list of all available site directory names in the Drupal installation. All sites/*
directories containing a settings.php
file are treated as individual sites.
Example: Usage
$ drall site:directories
default
donnie.com
leo.com
mikey.com
ralph.com
The output can then be iterated with scripts.
Example: Iterating
for site in $(drall site:directories)
do
echo "Current site: $site";
done;
site:aliases
Get a list of site aliases.
Example: Usage
$ drall site:aliases
@tmnt.local
@donnie.local
@leo.local
@mikey.local
@ralph.local
The output can then be iterated with scripts.
Example: Iterating
for site in $(drall site:aliases)
do
echo "Current site: $site";
done;
Site groups
Drall allows you to group your sites so that you can run commands on such groups with ease.
drall exec --drall-group=GROUP core:rebuild
Drall groups with site aliases
In a site alias definition file, you can assign site aliases to one or more groups like this:
# File: tnmt.site.yml
local:
root: /opt/drupal/web
uri: http://tmnt.com/
# ...
drall:
groups:
- cartoon
- action
This puts the alias @tnmt.local
in the cartoon
and action
groups.
Drall groups with sites.*.php
If your project doesn't use site aliases, you can still group your sites using one or more sites.GROUP.php
files like this:
# File: sites.bluish.php
$sites['donnie.drall.local'] = 'donnie';
$sites['leo.drall.local'] = 'leo';
This puts the sites donnie
and leo
in a group named bluish
.
Development
Here's how you can set up a local dev environment.
- Clone the
https://github.com/jigarius/drall
repository.- Use a branch as per your needs.
- Run
docker compose up -d
. - Run
docker compose start
. - Run
make ssh
to launch a shell in the Drupal container. - Run
make provision
. - Run
drall --version
to test the setup. - Run
make lint
to run linter. - Run
make test
to run tests.
You should now be able to make ssh
and then run drall
. A multi-site Drupal installation should be present at /opt/drupal
. Oh! And Drall should be present at /opt/drall
.
Hosts
To access the dev sites in your browser, add the following line to your hosts file. It is usually located at /etc/hosts
. This is completely optional, so do this only if you need it.
127.0.0.1 tmnt.drall.local donnie.drall.local leo.drall.local mikey.drall.local ralph.drall.local
The sites should then be available at:
- http://tmnt.drall.local/
- http://donnie.drall.local/
- http://leo.drall.local/
- http://mikey.drall.local/
- http://ralph.drall.local/
Acknowledgements
- Thanks Symetris for funding the initial development.
- Thanks Jigar Mehta (Jigarius) (that's me) for spending evenings and weekends to make this tool possible.