This project was built using the drupal-project
Drupal Composer template, and is used to demonstrate Drupal VM's local and production environment management capabilities.
The motivation behind this project and the process to build the initial version are documented in Jeff Geerling's blog post Soup to Nuts: Using Drupal VM to build local and prod.
You should have the following installed on your local environment prior to working on this project:
- Vagrant, VirtualBox and Ansible
- PHP and Composer
- Vagrant plugins:
vagrant-vbguest
,vagrant-hostsupdater
If this is the first time you've cloned the project, run the following commands to get started developing:
composer install
vagrant up
(you'll need to enter the Vault password at this point)
Once that's completed, you can visit http://local.drupalvm.com/ in your browser to see the site locally.
Note: You can remove the
secrets.yml
file from thevm
directory if you want to avoid using the vault password for testing purposes. For the local environment, the variables in that file are overridden invagrant.config.yml
anyways.
- Edit your hosts file, and add the line:
192.168.88.10 local.drupalvm.com
- (If on Mac) Add an alias for the container's IP address:
sudo ifconfig lo0 alias 192.168.88.10/24
- Run
docker-compose up -d
. - Export the database from prod.drupalvm.com using MySQL.
- Import the database into the local environment using MySQL.
Once that's completed, you can visit http://local.drupalvm.com/ in your browser to see the site locally.
To run Drush commands on the site, wrap the commands in docker exec
, like so:
docker exec local-drupalvm bash -c "drush --uri=local.drupalvm.com --root=/var/www/drupalvm/drupal/web status"
- Create a DigitalOcean Droplet (or basically any other VPS that gives you full control/root). The root user account on this VM should have your SSH key already added.
- Copy the
example.vars.yml
file tovars.yml
insidevendor/geerlingguy/drupal-vm/examples/prod/bootstrap/
(for one-time use), and customize to your liking. - Run the initialization playbook from the project root directory:
ansible-playbook -i vm/inventory vendor/geerlingguy/drupal-vm/examples/prod/bootstrap/init.yml -e "ansible_ssh_user=root"
- Run the main Drupal VM playbook to build the server:
DRUPALVM_ENV=prod ansible-playbook -i vm/inventory vendor/geerlingguy/drupal-vm/provisioning/playbook.yml -e "config_dir=$(pwd)/vm" --become --ask-become-pass
Notes:
- Only the repository's owner has the SSH keys for accessing the actual live
prod.drupalvm.com
site, and the Vault password for the protected variables insidesecrets.yml
. - When running the production playbook, you should ensure a
~/.ansible/prod-drupalvm-vault-password.txt
file exists, containing one line with the Vault password used to encrypt thevm/secrets.yml
file. If the password file is not present, pass--ask-vault-pass
to theansible-playbook
command and enter the password at runtime.
If you decide to store some private variables in an Ansible Vault-encrypted vars file, then you should run all Vagrant commands like:
DRUPALVM_ANSIBLE_ARGS='--ask-vault-pass' vagrant [command]
And when running Ansible commands, use:
ansible-playbook [args] --ask-vault-pass
You can also pass a file path containing the vault password, if you need to do automated deployments. See Ansible's Vault Documentation for more info.
This codebase includes Behat behavioral tests in the tests
directory. To run the tests, make sure you have the local environment running, then inside the tests directory, run:
# If using Drupal VM with Vagrant locally accessed at `local.drupalvm.com`.
../vendor/bin/behat --config behat.yml
# If using Drupal VM with Docker locally accessed at `localhost`.
../vendor/bin/behat --config behat-docker.yml
This project is maintained by Jeff Geerling, author of Ansible for DevOps and maintainer of Drupal VM.