This project builds on the Drupal Dev VM to create a single configuration tool for both local and remote Drupal sites. There is much more detailed information about this project in the tutorial.
It current includes the following Ansible roles created by Jeff Geerling:
- geerlingguy.git
- geerlingguy.firewall
- geerlingguy.ntp
- geerlingguy.repo-epel
- geerlingguy.repo-remi
- geerlingguy.postfix
- geerlingguy.mysql
- geerlingguy.apache
- geerlingguy.php
- geerlingguy.php-mysql
- geerlingguy.composer
- geerlingguy.drush
It also includes two additional geerlingguy roles, modified slightly to handle the project requirements:
It should take 5-10 minutes to build or rebuild the VM from scratch on a decent broadband connection.
There are a handful of things you will need to configure to use this on your site, including:
provisioning/inventory
: where you will define your hostsprovisioning/host_vars/*
: You will need to update these to map to your hostnames from the inventoryprovisioning/vars/main.yml
: Which you will need to copy fromprovisioning/vars/main.yml.example
. It contains variables related to the firewall, ssh access, Git repository url, and Drupal configuration, etc.provisioning/group_vars/all
(copied fromprovisioning/group_vars/all.example
): Where you define yourdeploy_user
provisioning/group_vars/droplets
(copied fromprovisioning/group_vars/droplets.example
): Additional security settings and private key setup for your remote ssh connection
- Download and install VirtualBox.
- Download and install Vagrant.
- [Mac/Linux only] Install Ansible.
- Install Ansible Galaxy roles required for the project:
$ ansible-galaxy install -r requirements.txt
Note for Windows users: This guide assumes you're on a Mac or Linux host. The main difference is Ansible needs to be bootstrapped from within the VM after it's created. See JJG-Ansible-Windows for more information.
- Download this project and put it wherever you want.
- Clone the Git repository you configured in
provisioning/vars/main.yml
in the same parent folder as this project. This is required locally (due to the synced_folder defined in the Vagrantfile), but not on the remote server. - Configure the required files in the "Customizing the Project" section above.
- Open Terminal, cd to this directory (containing the
Vagrantfile
and this REAMDE file). - Type in
vagrant up
, and the first time, Vagrant will configure the deploy user account - Change
initialized
totrue
and eithervagrant provision
, oransible-playbook provisioning/playbook.yml -i provisioning/inventory --limit=dev
Note: If there are any errors during the course of running vagrant up
, and it drops you back to your command prompt, just run vagrant provision
to continue building the VM from where you left off. If there are still errors after doing this a few times, post an issue to this project's issue queue on GitHub with the error.
- Edit your hosts file, adding the line
192.168.88.88 [yourdomain].dev
so you can connect to the VM. - Open your browser and access http://[yourdomain].dev/
- Assuming that you have root access to a remote server with your ssh key already added, test Ansible's ability to connect by heading to the
provisioning
folder in your terminal and typingansible [host] -i inventory -m ping
, ie:ansible staging -i inventory -m ping
, where "staging" matches a host defined in your inventory. - Enable verbose output if you have an issue, otherwise, configure your deploy user with
ansible-playbook deploy_config.yml -i inventory --limit=staging
. - If that finishes without errors, you are ready to configure the site on your remote server with
ansible-playbook playbook.yml -i inventory --limit=staging
.
- To shut down the virtual machine, enter
vagrant halt
in the Terminal in the same folder that has theVagrantfile
. To destroy it completely (if you want to save a little disk space, or want to rebuild it from scratch withvagrant up
again), type invagrant destroy
. - You can change the installed version of Drupal or drush, or any other configuration options, by editing the variables within
provisioning/vars/main.yml
. - Find out more about local development with Vagrant + VirtualBox + Ansible in this presentation: Local Development Environments - Vagrant, VirtualBox and Ansible.
- Learn about how Ansible can accelerate your ability to innovate and manage your infrastructure by reading Ansible for DevOps.
Aaron Froehlich, is a Passionate Programmer and Drupal developer at Cornell University. He created this project in 2014 so he could launch his Drupal 8 site and as a playground for Ansible, which he is learning from Jeff's book, Ansible for DevOps.