According to Anarcat:

In general, I think it's bad practice to run provision-* commands in hook_post_hosting_task(). The purpose of this task is to collect stuff that was generated in the backend so that it propagates to the frontend.

What you really want to do is post_provision_verify() or post_provision_install() tasks. They make it much clearer when you're running and why. That way, you don't have to go through hoops to detect if the role is already there - if you run on install, then of course the role isn't there and you just add it. This would simplify the code significantly, at the cost of splitting it in frontend/backend modules.

And so, we should be using post_provision_verify() or post_provision_install(), which I believe will mean using d() to pull in the context. Thankfully, darthsteven has provided some good guidance here: http://community.aegirproject.org/node/322

Comments

ergonlogic’s picture

BTW, this means creating a separate project for the backend stuff: provision_profile_roles, I guess.

See #1214254: Interesting IRC discussion for discussion on the topic.

ergonlogic’s picture

Project: Hosting Profile Roles » Aegir Services
Version: 6.x-1.x-dev » 7.x-3.x-dev
Component: Code » Aegir SaaS
Category: Task » Bug report
Issue summary: View changes

Since "Hosting Profile Roles" has largely been merged into Hosting SaaS, which has, in turn, been merged into Aegir Services, this issue should belong here now.

One of the original blockers for this refactoring was the requirement to create a new backend project. With Aegir 3+ this in no longer the case. The relevant code currently resides here: http://cgit.drupalcode.org/hosting_services/tree/submodules/hosting_saas...

colan’s picture

I thought this would get easier with Storing data in Aegir (assuming it's still relevant), but it's non-trivial.

The data we'd need for each site is:

  • saas_create_subscriber_name (string)
  • saas_create_subscriber_email (string)
  • saas_set_subscriber_role (string)
  • sass_send_subscriber_email (boolean)

Looks like we would need to:

  1. Save these to $arguments in AegirSaasCreateSiteTaskGenerator->prepareClientUserInfo().
  2. Modify the drupal_alter() in hosting_services_save_site() to provide $data as context (containing the above).
  3. Implement hook_hosting_services_site_presave_alter() in SaaS to add the data to the site node.
  4. Do whatever's necessary to get that data from the front-end to the back-end, possibly setting up a service as per the blog post above.