Hi guys,

I have a case where I need to append to the vhost config template created in provision_apache.drush.inc

At the moment redirection and aliases can add to the template in _provision_apache_create_vhost_config(). Here is a patch that allows other drush modules to do the same.

Cheers,
Ben

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adrian’s picture

we already have a hook for this

  $options['extra_config'] .= join("\n", drush_command_invoke_all('provision_apa
che_vhost_config', $url, $options));
anarcat’s picture

Well, this is different: the hook allows *templates* to be added, as opposed to adding stuff to within the block. This could make the redirection code a lot cleaner for example:

  if (!empty($options['redirection'])) {
    $template .= _provision_apache_redirect_template();
  }
benkant’s picture

Yep, this patch is to allow you to add to the template file, outside of the existing VirtualHost block.

sime’s picture

With this feature you'd have two separate methods to add to a vhost file.

I had a desire earlier today to be able to replace * with an IP. That's a third that AFAICT is not covered by this.

Is there a place for drupal_alter on a whole vhost contents?

benkant’s picture

Perhaps being able to alter the whole vhost contents would take care of all possible issues that might arise with this config file.

sime’s picture

I feel that too benkant. If that was in place then we could solve unusual setups with 3rd party addons (or roll your own).

Anonymous’s picture

Status: Needs review » Needs work

Could we please have a new patch rolled against the latest in git master branch (multiserver got merged in and everything is different in provision now)

Thanks!

benkant’s picture

Stay tuned I will roll a new patch when I'm back at work Monday.

benkant’s picture

We're not on HEAD anymore and are using releases. Any chance someone else can reroll this?

adrian’s picture

head is now completely completely different.

just so you know.

adrian’s picture

ok.

we can't alter the contents of the vhost, because we dont actually have a full representation of it.
we would need to write a parser for virtualhost files and then rewrite it for each of the additional web servers.

Another thing, is that with additional web servers being added , there's a high likelihood that your code will either break or best case scenario be completely ignored with other services.

i'm looking at what i can do in the config classes though.

Anonymous’s picture

The current API for provision_apache_vhost_config (and the platform and server ones) allow you to return a path to a .tpl.php rather than just raw data to be injected.

I don't know if that is enough to consider this fixed or not yet. I really find the case of 'i can't inject into a vhost and need to add a whole 'nother vhost or manage the whole thing' to be somewhat of a corner case, except maybe the case of alias redirection where the second vhost is made up of the first Alias.

If it needs to be outside of the vhost, it can go in the platform or server wide vhosts, for which there are similar APIs for now.

Steven Jones’s picture

Version: » 6.x-2.x-dev
Steven Jones’s picture

We should probably let people who want to swap out the Aegir template files with their own easily, which afaik we don't at the moment. I think this would be the only way to cover the corner cases we have now.

Steven Jones’s picture

Here's a simple version. I think that we need to make it easier to make sure templates can be suggested in a specific order and we need a specific way of picking one of the suggestions.

anarcat’s picture

Status: Needs work » Needs review
Steven Jones’s picture

Assigned: Unassigned » Steven Jones
Status: Needs review » Needs work

This should have an alter hook, not just the invoke.

Steven Jones’s picture

Status: Needs work » Fixed

Added the alter hook and pushed in 6.x-2.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit ec42e43 on dev-drupal-8, 6.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-subdir-multiserver, 6.x-2.x-backports, dev-helmo-3.x by Steven Jones:
    Issue #709862 by Steven Jones: Added Allow drush modules to add to...