Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Drush Aliases for all Sites in an Org? #779

Closed
joshkoenig opened this issue Dec 23, 2015 · 21 comments
Closed

Generate Drush Aliases for all Sites in an Org? #779

joshkoenig opened this issue Dec 23, 2015 · 21 comments

Comments

@joshkoenig
Copy link
Member

Currently the generation of Drush aliases relies on an API call that only puts sites a user is a direct team member of into the file.

https://github.com/pantheon-systems/cli/blob/80f31bb1c4ae61a6f2dac5ccebd6113f374ad66b/php/Terminus/Commands/SitesCommand.php#L46

Members of organizations do not have an easy way to get an aliases file for all the sites in the org, and when there are many sites the terminus drush ____ command is not very performant.

We could construct an alias file for all sites in an organization that would work for most purposes. It could save to $HOME/.drush/{orgname}.aliases.drushrc.php.

This would be a pretty heavy operation since it would require multiple API calls per site. If we wanted to support this we might need to develop something new on the backend to allow it to be efficient.

@joshkoenig
Copy link
Member Author

Heads up @ossobuffo and @greg-1-anderson :)

@cnovak
Copy link

cnovak commented Dec 23, 2015

I can see the difficulty in implementation, but would be great for our organization needs.

@TeslaDethray
Copy link
Contributor

@joshkoenig I have two versions of this which work and we could use.

This one does the processing in Terminus:
#800

This one makes the change on the API:
https://github.com/pantheon-systems/titan-mt/pull/14102

@bensheldon Prefers an API change, otherwise the Dashboard aliases will not be consistent with Terminus'. IMHO, I agree that that is the best solution. Why would anybody want an incomplete list of aliases?

@ossobuffo
Copy link

Whichever solution is chosen, it should take into account HTTP timeouts for organizations with ludicrous numbers of sites. With the old drush-based terminus, I could no longer fetch an aliases list because my HTTP connection would time out.

I don't know your internal architecture, but how about one task to queue generation of an aliases file on the server-side, and another task to fetch it once it's finished?

@peterfeddo
Copy link

Would love to see a performant solution for this with big organizations with lots of Pantheon sites and dev branches.

@greg-1-anderson
Copy link
Member

For teams with a very large number of sites, we are discussing improvements to site-local aliases. Historically these have had problems, but the situation is improving. See: drush-ops/drush#1532

@kellybell
Copy link

+1 on this request. I was just about to write this request up in the power users group, but assumed that I was just dumb and that it was already there somewhere. Ideally, I want to put whatever this command turns out to be into an "on-login" script that automatically runs every time I open Terminal.

@greg-1-anderson
Copy link
Member

With the recent introduction of machine tokens, automatic updating of your Drush aliases is well within reach.

Traditionally, this is what I have been doing:

$ alias ta
alias ta='tli && tsa'
$ alias til
alias tli='terminus auth login MYEMAILADDRESS'
$ alias tsa
alias tsa='terminus sites aliases'

I just run ta as needed. Now, though, it would be feasible to run ta from within .bashrc; just run terminus auth login with --machine-token once. Nifty.

@TeslaDethray
Copy link
Contributor

@kellybell I tried to get this change in a couple of ways, but it has been stymied by technical considerations. I adapted the command I wrote to do this task into a script using Terminus as a library. If you install pantheon-systems/cli from composer and use this script, you can generate all your aliases at once.
https://github.com/pantheon-systems/cli/blob/master/docs/examples/PantheonAliases.php

@kellybell
Copy link

I'm having issues getting terminus to work right now, but I'll try this as
soon as I can. Thanks so much for the tips!

K

On Jan 28, 2016, at 09:48, Sara McCutcheon notifications@github.com wrote:

I tried to get this change in a couple of ways, but it has been stymied by
technical considerations. I adapted the command I wrote to do this task
into a script using Terminus as a library. If you install
pantheon-systems/cli from composer and use this script, you can generate
all your aliases at once.
https://github.com/pantheon-systems/cli/blob/master/docs/examples/PantheonAliases.php


Reply to this email directly or view it on GitHub
#779 (comment).

@TeslaDethray
Copy link
Contributor

Addressed by the all-aliases Terminus plugin (https://github.com/pantheon-systems/all-aliases-plugin), closing issue.

@netgenius
Copy link

From a customer perspective, it's a PITA that the Download Drush aliases link on the my Dashboard page does not include sites which I have access to via Organizations. I don't use Terminus yet, not really sure if I want to. I will probably build the alias files manually. Please come up with a better solution, i.e. make Download Drush aliases do what customers expect it to do.

@kellybell
Copy link

That plugin has an unfixed known issue, which is resolved here:
https://github.com/jcowher/all-aliases-plugin

Kelly Bell
Founder and CTO
Gotham City Drupal
917-446-1555

On Sat, Feb 27, 2016 at 3:55 PM, Andy Inman notifications@github.com
wrote:

From a customer perspective, it's a PITA that the Download Drush aliases
link on the my Dashboard page does not include sites which I have
access to via Organizations. I don't use Terminus yet, not really
sure if I want to. I will probably build the alias files manually. Please
come up with a better solution, i.e. make Download Drush aliases do
what customers expect it to do.


Reply to this email directly or view it on GitHub
#779 (comment)
.

@aloyr
Copy link

aloyr commented Apr 7, 2016

Hi, came here also looking for an "all-aliases-plugin" that would work for organizations, and the link posted above now gives a 404 from github... Does anyone know what is the known issue with that plugin? There are zero issues on the github page for that plugin...

@aloyr
Copy link

aloyr commented Apr 7, 2016

nvm... I got it to work. Had to comment a line of code and increase the OS open file limit. This is my first day playing with terminus, so forgive any non-standard practices...

Increased file limit on OSX with

ulimit -n 4096

For the code change, I am not sure this is recommended for any hosts other than your own development box, and maybe not even then... but what I did was:

diff --git a/Commands/PantheonAliases.php b/Commands/PantheonAliases.php
index a51de3b..27a232b 100644
--- a/Commands/PantheonAliases.php
+++ b/Commands/PantheonAliases.php
@@ -22,7 +22,7 @@ class PantheonAliases extends TerminusCommand {
    */
   public function __construct(array $options = []) {
     parent::__construct($options);
-    $this->helpers->auth->ensureLogin();
+//    $this->helpers->auth->ensureLogin();
   }

   /**

After those 2 changes, the all-aliases plugin started to work for me.

@TeslaDethray
Copy link
Contributor

Might your version of Terminus be out of date, @aloyr? There was a problem with a big loop of file-openings, but I believe I'd fixed it.

@aloyr
Copy link

aloyr commented Apr 8, 2016

Hi @TeslaDethray, that's possible, although I believe I've updated terminus this morning via composer. I will check it tomorrow as that happened on my work computer.

@aloyr
Copy link

aloyr commented Apr 8, 2016

ok, composer seems to have only version 0.10.6 and github has 0.11.1, so I should probably just use the github version instead?

@greg-1-anderson
Copy link
Member

Use pantheon-systems/terminus. The pantheon-systems/cli project has been abandoned.

@aloyr
Copy link

aloyr commented Apr 8, 2016

hi greg. thanks for the info. i had pantheon-systems/terminus, but i was stuck on an old version... just changed my composer version to pantheon-systems/terminus dev-master instead...

@greg-1-anderson
Copy link
Member

Use '~0' if you only want to get tagged releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants