Drupal 10, the latest version of the open-source digital experience platform with even more features, is here.This patch is a simple change that introduces no changes to the existing behavior or UI.
Hopefully the change is small enough to include in the next 3.x release.
The new "install_method" property in this patch allows other systems to create Aegir Site nodes and to modify what happens after the codebase and services are setup..
Instead of running the install profile, you can skip it and allow the user to visit install.php. Or, you could run a different script, for example to import SQL.
This is currently impossible to do because there are no hooks or checks in place to alter the behavior:
// From provision/platform/install.provision.inc
function drush_provision_drupal_provision_install() {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
// call a backend task to do the actual installation.
$result = provision_backend_invoke(d()->name, "provision-install-backend", array(), array('client_email' => drush_get_option('client_email')));
}
After this patch, you can write custom Drupal code that does this:
function mymodule_node_load() {
$site_node->install_method = 'my_script'
}
function mymodule_post_hosting_install_task($task, $data) {
if ($task->ref->install_method == 'my_script') {
// Run a custom drush install
shell_exec("drush @{$task->ref->hosting_context} site-install somethingelse --crazy-option")
// Run whatever you want
$output = shell_exec('/usr/local/bin/launch_supersite');
// Import an existing SQL dump
shell_exec("drush @{$task->ref->hosting_context} sqlc < ~/sql/prepared_site.sql");
// Save data back to front-end if you want to.
$task->ref->my_script_results = $output;
}
}
Since $site_node->install_method is not "profile", it will not run the drupal profile, but everything will still be setup (database, settings, etc).
You can then check for that property in other hooks to do other things.
We are going to include this patch in the next release of DevShop (still on Aegir 3.x), I'll report back here on how that goes..
ORIGINAL ISSUE
Recently I've been working hard to add services to aegir to launch environments in docker, using Rancher: https://github.com/opendevshop/devshop_rancher
After getting all the way through to launching containers and deleting, I am completely blocked by the way Aegir installs Drupal. host. The install always fails because the local aegir user doesn't have root database access to the site database containers, and I don't want it to: I'd rather just use docker-compose.yml as the interface to manage the database containers, not direct MySQL.
I tried and tried, and I could not figure out a way to swap out an alternative install method.
The "install" task bootstraps your codebase locally, then uses the DB connection information to connect to your database from there, but aegir doesn't have access to the DB containers.
I think we need to decouple the "install" task, and offload all tasks short of running the install script itself to the verify task. I'm going to try and move create database and settings files to verify.
I think this is a first step in being able to support other types of systems like wordpress, and even static sites. It would also users to step through drupal install profiles themselves, which can be nice.
We can keep the current workflow the default, but we could benefit from making site install optional. Once we do this, we will also be able to use alternative installation methods.
I've started some preliminary patches. Looks like it might not be too hard at all. Pretty much everything that runs on install task is also ran on verify task.
Stand by for branches.
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | 2754069-drupal-sites-exist.patch | 1.22 KB | Jon Pugh |
| #24 | 2754069-decouple-install.patch | 15.71 KB | Jon Pugh |
| #24 | 2754069-decouple-install-alternate-provision.patch | 3.72 KB | Jon Pugh |











Comments
Comment #2
helmo CreditAttribution: helmo at Initfour websolutions commentedWould be nice... this might also help to make current remote servers smarter. Leaving install on the master server, and dispatching verify on the slave.
Comment #3
ergonlogicThis seems pretty drastic for a stable release. Let's move to 4.x.
Have you looked at how hosting_wordpress handles such things?
An alternative approach might be to follow the path we're taking with Aegir HTTPS. That is, fork hosting_site/platform into a separate repo (hosting_drupal?) and start splitting out the Drupal-specific stuff, merging the back-end code, etc. If it used a new namespace for the base stuff (hosting_app/hosting_codebase?), we might be able to use them as drop-in replacements in Aegir3 and become default in Aegir4.
Comment #4
colanComment #5
Jon PughWork in progress pushed to branches 'decouple-install' in hosting and provision projects.
Patches attached for easy visibility.
I was able to get a site node to run a verify task successfully, create the database and permissions, and write all the sites/x.com/ folders and files.
For some reason, however, I cannot `drush sqlc` or access the site. There must be some other step deep down in the install hooks
Lot's of lessons learned:
Much overlap between install and verify already.
We probably don't want to use verify as the "creation" step. It's too tricky to determine if it exists or not. A rollback hook would be in place for verify to destroy, which would be bad if the site already exists.
I think the way forward here would be to have a new "Create" task and we move all of the files/directory creation stuff to that.
That would align well with the "Create Site" form. We can add a "[ ] Install Drupal" checkbox that gets passed to the Create Task. If it's checked we either do the install within the create task or we trigger a separate install task.
There's still much more work to do here. We don't have a HOSTING_SITE_INSTALLED status for example. In the patches, the site's end up queued.
Comment #6
Jon PughThe first verify run on a blank drupal7 platform gets the message:
Could not find a Drupal settings.php file at sites/default/settings.php.
Comment #8
Jon PughHad a stroke of inspiration this morning and tracked down the code that actually triggers the drupal profile install, and wrapped it with a drush option.
It worked. I ended up with what appeared in the Aegir front-end as a fully installed site but really the install profile never ran. This is great, because the database exists and I was able to visit install.php to manually install Drupal.
In this code space we can do more, like import an existing SQL dump, copy data from another site, or even, install wordpress.
I'm still thinking about where to go from here.
Comment #11
Jon PughI got it to work! I devised a new "install_method" property on site_nodes when, if set to anything other than "profile", will skip the drupal profile install.
This means module authors can use node_load() or entity alter hooks to set $node->install_method to something else, then check for the drush option "site_install_method" in their hooks.
As an additional feature, I check for install_method = 'manual' and if it is set, it will set "login_link" to http;//domain/install.php!
The point of this is to make it possible to do alternate things on Aegir Site Install like import an SQL dump, or copy data from another site.
With this patch, the normal behavior stays the same. You must implement a hook_node_load() to add the property "install_method" to change the existing default behavior.
Comment #12
Jon PughComment #13
Jon PughComment #14
Jon PughComment #15
Jon PughI'm scaling back the scope of this issue to a simple change that introduces no changes to the existing behavior or UI.
Hopefully the change is small enough to include in the next 3.x release.
The new "install_method" property in this patch allows other systems to create Aegir Site nodes and to modify what happens after the codebase and services are setup..
This is currently impossible to do because there are no hooks or checks in place to alter the behavior:
After this patch, you can write custom Drupal code that does this:
Since $site_node->install_method is not "profile", it will not run the drupal profile.
We are going to include this patch in the next release of DevShop (still on Aegir 3.x), I'll report back here on how that goes..
Comment #16
Jon PughComment #17
Jon PughComment #18
Jon PughComment #19
helmo CreditAttribution: helmo at Initfour websolutions commentedI think this would need to be documented in hosting.api.php or maybe in example/site_data
In testing it on my feature/quick-review branches I did'n get it working...
I had added this dummy code to force the install method.
Another thing that needs attention is:
I think hosting_site_post_hosting_install_task() needs an extra condition...
Comment #22
Jon PughNew patches make "install_method" a true site context option property thing.
This way, reinstall task retains the install_method.
Comment #23
Jon PughUpdated from latest 7.x-3.x branch.
Comment #24
Jon PughComment #25
JamesK CreditAttribution: JamesK at Advisor Websites commentedHow would someone add code for handling their own install method? For example, perhaps there should there be a hook for discovering new install methods.
Import SQL would be a very good use case for this as a way of having templated default sites install much, much faster than using Clone.
Comment #26
Jon PughNew patches attached, branches in both provision and hosting modules:
2754069-decouple-installNote "alternate" branches and patches removed to reduce confusion.
TODO (but should not block committing):
Comment #27
Jon PughJamesK: The code looks for a string in
$site_node->install_method. If you set that property with a hook_node_load() or alter hook, then add this drush hook: (taken from devshop)I'm exploring how to best include this in core aegir, but it's a dramatic shift, so if we can allow it in core, then let aegir contrib handle alternate install methods, that would probably be best.
Comment #29
helmo CreditAttribution: helmo as a volunteer and at Initfour websolutions commentedI've merged both the hosting and provision branches.... Please follow up in #2890750: Provide UI to select install method for a new site
Comment #31
Jon PughI've found a few more issues with this.
Some code depends on the "installed" drush option, which is only set if the drupal profile install method is used.
I've created a branch that replaces drush_get_option('installed') with _provision_drupal_site_exists().
Comment #32
Jon PughComment #33
Jon PughTests pass, I'm merging!