This repo exists to suggest a template for organizing your new or existing Drupal project repo, to be compatible with the deploy-drupal cookbook. By following our suggestions, you will have a complete workflow for quickly getting a Vagrant VM that's ready to serve your as your complete dev environment, including:
This guide will cover the workflow around 3 main cases:
For this case, there is nothing to do. Simply run vagrant up
and the
deploy-drupal
cookbook will download the latest stable version of D7,
and run drush site-install
for to populate a clean Drupal database.
If you don't customize the settings in Vagrantfile
, then:
/vagrant
will be a synced mount of PROJECTROOT, containing this README.md./vagrant
will be copied to /var/shared/sites/cooked.drupal/
/var/shared/sites/cooked.drupal/site/
drush sql-dump --result-file
will be stored in /home/vagrant/drush-backups
PROJECTROOT/db
is a synced folder linked to /home/varant/drush-backups
After the initial deployment, it's recommended to commit the newly created site to a newly-created git repo, as follows:
vagrant ssh
cd /var/shared/sites/cooked.drupal
# make a backup of the site
drush --root='/var/shared/sites/cooked.drupal/site' sql-dump --gzip --result-file='../db/dump.sql.gz'
# clean up: remove README.md, etc.
echo "settings-priv.php sites/default/files" | tr ' ' '\n' >> .gitignore
git init
git add .
git commit -m "Fresh Drupal site created by deploy-drupal cookbook"
# create a new repo, say at github
git remote add origin https://github.com/USERNAME/NEWREPO.git
git push -u origin master
At this point, we recommend to blow away PROJECTROOT on the host, and recreate it from the NEWREPO.git, which can be done as follows:
# exit vagrant ssh
git remote set-url upstream https://github.com/USERNAME/NEWREPO.git
git pull # this will auto-merge your repo
git push -u origin master # pushes vagrant-chef commits (including this README.md) to your new repo
Now simply redeploy the Drupal dev environment from the new Drupal repository:
# alternative: RESET_DRUPAL=1 vagrant provision
vagrant destroy # be sure you committed and pushed all your code & db!
vagrant up
At this point we assume you have cloned a Drupal project repository, contianing a
Drupal codebase, SQL dump, and suitable Vagrantfile
and Berksfile
configurations.
Note that the default Vagrantfile
contains the following configuration for the
deploy-drupal
cookbook:
'drupal-deploy' => {
'sql_load_file' => '/vagrant/db/dump.sql.gz', # if non-existant, DB will be initialized via 'drush si'
'codebase_source_path' => '/vagrant/site', # if folder is empty, will download D7 instead
},
Adjust these as needed, then simply run vagrant up
to do the following:
/vagrant
/vagrant
to /var/shared/sites/cooked.drupal
, but only once./var/shared/sites/cooked.drupal/site
At this point,
/var/shared/sites/cooked.drupal/site
git pull
to update the codebase in $PROJECTROOT.$PROJECTROOT/db
will contain all the database dumps produced via drush sql-dump --gzip --result-file
. Commit these as appropriate.Vagrantfile
configuration by editing $PROJECTROOT/Vagrantfile
. Commit these as appropriate.These are a few pre-requisites to install:
vagrant plugin install vagrant-berkshelf
There are currently serious problems with deploy-drupal
and git:
deploy-drupal
makes it impossible to keep the Drupal site as a subfolder of the git repo
(eg PROJECTROOT/site).To hack on the deploy-drupal
cookbook, fork https://github.com/amirkdv/chef-deploy-drupal, then do the following:
mkdir site-cookbooks
git clone https://github.com/USERNAME/chef-deploy-drupal.git site-cookbooks/deploy-drupal
vim Berksfile # uncomment the following line: cookbook 'deploy-drupal', :path => 'site-cookbooks/deploy-drupal'