terra-ops / terra-cli

The Terra Command Line Interface
http://terra.readthedocs.org
GNU General Public License v2.0
48 stars 17 forks source link

terra-cli support for Drupal Console #122

Open jameswilson opened 8 years ago

jameswilson commented 8 years ago

We have a situation where a Drupal 8 project needs to use Drupal Console,

The --target option can also be used like Drush @alias, so the syntax on cli commands can be exactly the same, and we can leverage {{alias}} in the hook section of .terra.yml scripts.

The problem is that although the same syntax on the cli can be used, the actual targets themselves must be redefined in a separate file in ~/.console/sites/ folder because Drupal Console will not read ~/.drush/*.aliases.drushrc.php. See the relevant console documentation for the format of the files in ~/.console/sites/ folder.

You end up with these errors:

$ drupal cache:rebuild all @terra.appname.environment --no-interaction                                                                                                          
  [PDOException]                                                                                                     
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known

  [PDOException]                                                                                                  
  PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known                                                                                                    

The terra architecture leverages a separate Drush container instead of logging directly into one of the app images to run Drush commands. So my thinking is that we would need to build a similar support straight into terra to provide an optional Drupal Console container and build in support into terra for creating Drupal Console "targets" when we create Drupal aliases. The missing step is to auto-generate the targets inside ~/.console/sites/terra.{appname}.yml when we generate ~/.drush/terra.{appname}.aliases.drushrc.php.

Is this a sound way to approach this problem? I'm not quite sure how we could offer an optional image for the docker-compose.yml file though. Maybe we just need to leave the Drupal Console container as part of the .terra.yml file, and let each drupal 8 project build their own? Seems kind of dirty though, we'll still need a way to determine inside terra whether or not to create the site targets file, which I also dont have a good idea how to do that.

Looking forward to your insights @jonpugh

jonpugh commented 8 years ago

The drush container is really just an SSH daemon.

It has drush installed but I don't know if it's even needed.

I could be wrong, but I think DrupalConsole's alias files can specify remote host and user just like drush aliases, and I don't think that DrupalConsole has to be installed on the target server.... can @jmolivas confirm?

The main step is, like you are doing now, is to add those console alias files.

Looking forward to getting these two projects playing together!