hashbangcode / vlad

Vlad - Vagrant LAMP Ansible Drupal
173 stars 53 forks source link

Add support for importing Pantheon sites. #292

Closed wizonesolutions closed 8 years ago

wizonesolutions commented 8 years ago

This is a new Vlad role (which could later possibly be spun out into its own standalone role) that allows importing database and files from Pantheon given some credentials and config.

The reason it's not an external role at this time is because it backpacks off a couple other roles, namely pantheon_cli and Vlad's built-in mysql role.

It uses Pantheon CLI to get the terminus command, and it uses the mysql role's mysql_import functionality so that it doesn't have to re-implement database import itself. Instead, it can just ensure it saves the right file to the right place and runs before the mysql role.

Care is taken not to overwrite people's existing data unless they delete the previously-saved files. Even then, we always make sure to move (not delete) the database file, since it might be auto-saved from halt, reload, or destroy. We do always replace the files directory; I felt backing that up would provide little value at this stage for the 2x disk space it would consume.

Future improvements would be smarter Pantheon CLI auth (can check if already authed before re-authing); more secure storage of Pantheon CLI credentials (perhaps we could suggest a .pantheon_cli config file to them, which if present would be read, and then shuttle the user's .pantheon_cli config file to the VM like we do with .gitconfig and such); more freedom on the first DB name; being able to import code from Pantheon as well and populate the docroot with it.

I didn't include cloning at this point because 1) I didn't need it myself; we use separate repositories for dev and then push those to Pantheon when we're ready to deploy, and 2) I figured others may have similar workflows, and cloning isn't really that hard. And 3) I have to implement it differently, probably with the Ansible git module. The backup we get from Pantheon has no predictable pattern once unarchived. So I couldn't just copy-paste-change this part, and I didn't feel it was worth spending time on vs. being able to deliver something.

wizonesolutions commented 8 years ago

Docs: https://github.com/hashbangcode/vlad-docs/pull/14

philipnorton42 commented 8 years ago

Sorry, been busy this week so haven't had a chance to review. Looks great! Thanks for all your hard work :)