Drupal 10, the latest version of the open-source digital experience platform with even more features, is here.I was going to raise a feature request, or even build it myself, but I found a shortcut.
The Aegir "Create Platform" UI allows us to deploy a new codebase from a makefile, but not to deploy from source control.
Our dev team has a load of sites, all of them in source control(s), all built and checked in from drupal root. I'm trying to rebuild our dev environment (dev - not live deployments) to be managed by a hostmaster management console.
I investigated and trialled some tools like hosting_upload, hosting_site_git, provision_git and even almost devshop_provision
After not quite getting there, and having a few drinks ... I figured I could get exactly what I wanted by building a minimal makefile!
Using the magiv of git make, I made a file like so:
; Get a full package from our git repo
core = 7.x
api = 2
projects[drupal][type] = core
projects[drupal][download][type] = git
projects[drupal][download][url] = git@git.coders.co.nz:clientname/projectname.git
projects[drupal][download][revision] = master
And now, when I ask Aegir to use that makefile, it pulls our whole project as the most recent git version. As one big stable lump. Sweet.
Ideally, our sites would be defined by real makefiles that could build from scratch, maybe, but with all the undocumented custom stuff that these projects end up having (most are legacy) that's heaps of retro-work. I'm just migrating their handmade dev environment into something manageable.
I'd still think it was pretty cool if I could enter a git or svn URL into the "Create Platform" page and let it do its thing! But I thought I'd share this idea tonight.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 1849304-hosting-platform_git_remote.patch | 6.62 KB | Jon Pugh |
| #3 | 1849304-platform_git_remote.patch | 2.45 KB | Jon Pugh |











Comments
Comment #1
Steven Jones CreditAttribution: Steven Jones commentedCould you document this on the community site please?
http://community.aegirproject.org
Comment #2
Jon PughI was in your exact situation when I started down the path of creating provision_git and devshop.
At the time, I too thought just creating a platform from git would make a good feature for aegir core, but then my goals widened to include wanting to group multiple platforms together somehow to better manage dev/test/live platforms+sites for each project.
I am currently working on a wizard for devshop for creating projects from a git url, then choosing which branches of your repo you want to build platforms for. This includes choosing if you even want dev/test/live platforms. (currently devshop automatically creates all 3 no matter what).
Now, I am working on keeping track of all branches and tags of your remotes, and making platforms branch aware, so you can create branch platforms on the fly.
However, the scope of devshop is much larger than what you are asking for here, simply allowing a git url to be stored in addition to a makefile.
I strongly agree this would be a great core feature of aegir. It would be MUCH simpler to implement in hosting/provision itself than as an add-on module. I know because I tried. hosting_platform_schema() already stores makefile in its DB and the provision context.
To do this, you would have to add "git_url" to the hosting_platform_schema(), hosting_platform_form() (the node form), and then add it to provision.context.platform.inc.
Then, in verify.provision.inc, is where you should do the git clone. See the line where it mentions "Makefile".
In fact, if this were the way aegir worked, devshop wouldn't have to deal with the git urls, which would make our lives much easier, so I may go ahead and get a patch rolling for this!
Comment #3
Jon PughProvision patch attached!
Based on 1.x dev, for now.
Almost have a patch for hostmaster working.
Comment #4
Jon PughTo test, apply the patch to provision, then manually save a new platform:
If root folder doesn't exist, it will clone the git_remote and the chosen branch!
If the root folder DOES exist, and there is a specified git_branch, it will git checkout $git_branch.
Comment #5
dman CreditAttribution: dman commentedI <3 that someone else is on board with this.
I agree, from a cursory examination, that trying to hijack the existing form and process is tricky from an outside add-on module.
This drush command looks like what I was thinking, and already have a local shell script that does similar stuff on my own project-specific un-portable way.
I'll try this out!
Comment #6
Jon PughAttached is the patch for hostmaster. Figured, at least to start they should be in the same issue.
Comment #7
dman CreditAttribution: dman commentedNotes-to-self.
Based on an aegir-up full VM. To apply these patches:
... then run update.php.
Testing now...
Comment #8
ergonlogic@dman: fyi, using the aegir-dev blueprint from aegir-up, you can specify arbitrary repos, branches, makefile, etc. from which to install Aegir.
Comment #9
dman CreditAttribution: dman commentedNotes:
Ensure that the Aegir user has already authenticated/pushed an ssh key to the target git server (if remote)
* ssh log in, su to aegir.
* do an experimental git clone from your secure repository, answer yes when prompted about the RSA key fingerprint
* you should NOT be prompted for a password. If so, you need to push a key, or the provision process will not be able to do its thing.
Note 2 (because I always forget)
To hurry up the hosting dispatch batch jobs
* ssh log in as aegir
* drush -v '@hostmaster' hosting-dispatch
Anyway - I'm getting GREEN results on the newly checked-out git repo, and was able to use it as a base site.
I *wanted* to get it to pull a specific tag, and entered that in the 'branch' box (just to try) but looks like
it just got the end of the master branch. That's fine. Defining a tag may be a different feature request.
Overall, this works from creating a platform from git exactly as I was hoping for!!
May need some probing for managing error conditions (like network or authentication failures) as I don't see much protection against that in the code yet.
Comment #10
anarcat CreditAttribution: anarcat commenteddo we really need this to be a *big* text? a git remote is just a URL and should be of an appropriate size. for example, the site name is a node title, and is a varchar(255).
also, shouldn't we make this more abstract in the frontend? we could just call this "repository", that way we won't have to change the API/database layer if someone wants to add (say) SVN support to the backend...
i know this may be nitpicking, but shouldn't this be called git_rev? git can checkout tags or specific revs... and with the "backend-neutrality" approach, we might as well just call this 'revision'...
please use the schema API here instead of hardcoding MySQL queries.
the backend changes seem fine, but the same comments about the naming of parameters apply. i am fine with just supporting git in the backend right now, mind you, we may want to add a vcs_type parameter along the way when we extend this. in fact, ideally, this would allow third party modules to extend the backend for that kind of stuff, but i don't think this should be required for this to get in.
oh, and please send patches for 2.x about this, I don't think it's fair to commit such a huge change to our stable release branch.
thanks!
Comment #11
Jon PughRe: git_remote field: I duplicated makefile schema field exactly.
I think it should be just like the makefile URL. Some services like pantheon and acquia use crazy long URLs for git repos because its secure for some reason, or they are in clouds. Does it hurt anything to keep it "big text"? I would argue that whatever the decided URL character limit would be essentially arbitrary, its better to let people make it too big than have to hack hosting tables.
On the flip side... Is there an actual http url length limit?? If we want to change the schema, might as well match that, right?
RE: the update_N: Again I copied makefile, so if we do, we should also change how the makefile column is setup:
RE: 2.x: Absolutely! I started on 1.x knew I could get the ball rolling quickly since I've been messing with this exact code for almost a year. I got this sucker working in about an hour the other day, and looking at the Diff with 2.x, it shouldn't take long to get it going there.
Comment #12
anarcat CreditAttribution: anarcat commentedThe makefile hook_update_N is old, we don't need to patch it. But further updates should use the schema API.
For the URL length, there is apparently no limit in the HTTP standard, but in practice URLs longer than 2048 do not work in IE (for example). See http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-... for a discussion about this. A big text is 4GB of storage: https://drupal.org/node/159605. That seems like an insanely long URL. Do the Acquia and Pantheon URL cross the varchar 255 boundary?
It does hurt a database to ask it for too much storage: the first are harder to search for one...
As for the name, I don't think we should restrict ourselves to drush_make's idiosyncracies...
Oh, and while I'm thinking about this out loud - why don't we use drush's git functions instead of rolling out our own? Seems like we would save a lot of work...
Comment #13
dman CreditAttribution: dman commentedRE Naming, I'd also expect we could use 'revision' instead of 'git_branch' - but I'd have done that for full 1:1 conformity with drush_make syntax.
There is zero reason why exactly this solution can't be re-used for an svn repo, or the next big VCS that comes along - and that's what drush make is playing towards and why its a bit generic with naming.
For sanity, I'd usually *start* with 255 varchar until it was proven to need to be longer. I wouldn't make it a sticking point either way however. Go for 1024 and move on.
This as a solution is really making me happy for the migrations I've got lined up this month. No more file-copies, I'll be rebuilding our sites from the repos ... and if there is something on our old sites that's not in the repo - we'll want to know why!
Comment #14
anarcat CreditAttribution: anarcat commentedSo let's reroll with varchar 255 and revision instead of git_branch. Consider the idea of adding a vcs_type variable while we're here and add hooks to extend this in the backend. Thanks again.
Comment #15
victorcoder CreditAttribution: victorcoder commentedVote up for this
Comment #16
anarcat CreditAttribution: anarcat commentedCan someone reroll this patch with the latest suggestions?
Comment #17
cweagansI don't think rc's are a good point to start introducing new features. For 6.x-2.x users, see provision_platform_git and hosting_platform_git. Let's definitely get this into 7.x-3.x, though. It's a very useful feature to have!
Comment #18
z.stolar CreditAttribution: z.stolar commentedhas there been any progress with this?
Comment #19
helmo CreditAttribution: helmo commentedI think we can call think fixed.
The hosting_platform_git module works with Aegir 2.x.
And #2180053: Include more "golden" contrib has discussion about that being integrated into Aegir 3