Ansible Drupal LAMP Stack
It current includes the following Ansible roles created by Jeff Geerling:
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.
Customizing the Project
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 hosts
provisioning/host_vars/*: You will need to update these to map to your hostnames from the inventory
provisioning/vars/main.yml: Which you will need to copy from
provisioning/vars/main.yml.example. It contains variables related to the firewall, ssh access, Git repository url, and Drupal configuration, etc.
provisioning/group_vars/all.example): Where you define your
provisioning/group_vars/droplets.example): Additional security settings and private key setup for your remote ssh connection
Quick Start Guide
1 - Install dependencies (VirtualBox, Vagrant, Ansible)
- 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.
2 - Build the Virtual Machine
- Download this project and put it wherever you want.
- Clone the Git repository you configured in
provisioning/vars/main.ymlin 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
Vagrantfileand this REAMDE file).
- Type in
vagrant up, and the first time, Vagrant will configure the deploy user account
vagrant provision, or
ansible-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.
3 - Configure your host machine to access the VM.
- Edit your hosts file, adding the line
192.168.88.88 [yourdomain].devso you can connect to the VM.
- Open your browser and access http://[yourdomain].dev/
4 - Configure your remote server
- 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
provisioningfolder in your terminal and typing
ansible [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 haltin the Terminal in the same folder that has the
Vagrantfile. To destroy it completely (if you want to save a little disk space, or want to rebuild it from scratch with
vagrant upagain), type in
- You can change the installed version of Drupal or drush, or any other configuration options, by editing the variables within
- 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.
About the Author
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.