├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── Vagrantfile ├── docs ├── deployment │ ├── drush-make.md │ ├── local-codebase.md │ └── multisite.md ├── extras │ ├── behat.md │ ├── drupal-console.md │ ├── drush.md │ ├── mailhog.md │ ├── mariadb.md │ ├── mysql.md │ ├── nodejs.md │ ├── pimpmylog.md │ ├── scripts.md │ ├── solr.md │ ├── ssl.md │ ├── syncing-folders.md │ ├── varnish.md │ ├── xdebug.md │ └── xhprof.md ├── images │ └── drupal-vm-logo.png ├── index.md └── other │ ├── base-os.md │ ├── bigpipe.md │ ├── drupal-6.md │ ├── linux.md │ ├── local-vagrantfile.md │ ├── management-tools.md │ ├── networking.md │ ├── php-7.md │ ├── vagrant-virtualbox.md │ ├── webservers.md │ └── windows.md ├── example.config.yml ├── example.drupal.make.yml ├── examples ├── acquia │ ├── README.md │ └── acquia.overrides.yml ├── prod │ ├── README.md │ ├── bootstrap │ │ ├── example.vars.yml │ │ └── init.yml │ ├── example.inventory │ └── prod.overrides.yml └── scripts │ ├── README.md │ └── configure-solr.sh ├── mkdocs.yml ├── provisioning ├── JJG-Ansible-Windows │ ├── LICENSE │ ├── README.md │ └── windows.sh ├── playbook.yml ├── requirements.yml ├── tasks │ ├── apparmor.yml │ ├── build-makefile.yml │ ├── cron.yml │ ├── dashboard.yml │ ├── drush-aliases.yml │ ├── extras.yml │ ├── init-debian.yml │ ├── init-redhat.yml │ ├── install-site.yml │ ├── sshd.yml │ └── www.yml ├── templates │ ├── dashboard.html.j2 │ ├── drupalvm-local.aliases.drushrc.php.j2 │ ├── drupalvm.aliases.drushrc.php.j2 │ ├── drupalvm.vcl.j2 │ └── nginx-vhost.conf.j2 └── vars │ └── main.yml └── tests ├── Dockerfile.centos-7 ├── Dockerfile.ubuntu-14.04 ├── centos-7-vars.yml ├── initctl_faker ├── test-vars.yml └── ubuntu-14-nginx.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | .project/ 4 | .vagrant/ 5 | .bundle/ 6 | *.retry 7 | vagrant_ansible_inventory_default 8 | config.yml 9 | drupal.make.yml 10 | Vagrantfile.local 11 | examples/prod/inventory 12 | examples/prod/bootstrap/vars.yml 13 | scripts/ 14 | roles/ 15 | drupal/ 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | sudo: required 3 | 4 | env: 5 | global: 6 | - CONFIG: example.config.yml 7 | MAKEFILE: example.drupal.make.yml 8 | HOSTNAME: drupalvm.dev 9 | MACHINE_NAME: drupalvm 10 | IP: 192.168.88.88 11 | matrix: 12 | - distribution: ubuntu 13 | version: 14.04 14 | init: /sbin/init 15 | run_opts: "--privileged" 16 | - distribution: ubuntu 17 | version: 14.04 18 | init: /sbin/init 19 | run_opts: "--privileged" 20 | additional_vars: ubuntu-14-nginx.yml 21 | - distribution: centos 22 | version: 7 23 | init: /usr/lib/systemd/systemd 24 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 25 | additional_vars: "centos-7-vars.yml" 26 | 27 | services: 28 | - docker 29 | 30 | before_install: 31 | # Pull container 32 | - 'sudo docker pull ${distribution}:${version}' 33 | # Customize container 34 | - 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests' 35 | # Install lint tools. 36 | - 'gem install rubocop' 37 | 38 | script: 39 | - container_id=$(mktemp) 40 | 41 | # Run container in detached state 42 | - 'sudo docker run --detach --volume="${PWD}":/var/www/drupalvm/:rw ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"' 43 | 44 | # Set hostname. 45 | - 'sudo docker exec "$(cat ${container_id})" hostname ${HOSTNAME}' 46 | 47 | # Setup directories. 48 | - 'sudo docker exec "$(cat ${container_id})" mkdir -p /var/www/drupalvm/drupal' 49 | 50 | # Install dependencies. 51 | - 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /var/www/drupalvm/provisioning/requirements.yml' 52 | 53 | # Copy configuration files into place. 54 | - 'sudo docker exec "$(cat ${container_id})" cp /var/www/drupalvm/$CONFIG /var/www/drupalvm/config.yml' 55 | - 'sudo docker exec "$(cat ${container_id})" cp /var/www/drupalvm/$MAKEFILE /var/www/drupalvm/drupal.make.yml' 56 | 57 | # Append additional variables. 58 | - 'sudo docker exec "$(cat ${container_id})" bash -c "cat /var/www/drupalvm/tests/test-vars.yml >> /var/www/drupalvm/config.yml" || true' 59 | - '[[ $additional_vars ]] && sudo docker exec "$(cat ${container_id})" bash -c "cat /var/www/drupalvm/tests/${additional_vars} >> /var/www/drupalvm/config.yml" || true' 60 | 61 | # Vagrantfile syntax check 62 | - 'rubocop --except LineLength,Eval,MutableConstant' 63 | 64 | # Ansible syntax check. 65 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /var/www/drupalvm/provisioning/playbook.yml --syntax-check' 66 | 67 | # Run the playbook with ansible-playbook. 68 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /var/www/drupalvm/provisioning/playbook.yml' 69 | 70 | # Run the integration tests 71 | - > 72 | sudo docker exec "$(cat ${container_id})" curl -s --header Host:${HOSTNAME} localhost 73 | | grep -q 'Welcome to Drupal' 74 | && (echo 'Drupal install pass' && exit 0) 75 | || (echo 'Drupal install fail' && exit 1) 76 | 77 | - > 78 | sudo docker exec "$(cat ${container_id})" curl -s --header Host:adminer.${HOSTNAME} localhost 79 | | grep -q '<title>Login - Adminer' 80 | && (echo 'Admin install pass' && exit 0) 81 | || (echo 'Adminer install fail' && exit 1) 82 | 83 | - > 84 | sudo docker exec "$(cat ${container_id})" curl -s --header Host:pimpmylog.${HOSTNAME} localhost 85 | | grep -q '<title>Pimp my Log' 86 | && (echo 'Pimp my Log install pass' && exit 0) 87 | || (echo 'Pimp my Log install fail' && exit 1) 88 | 89 | - > 90 | sudo docker exec "$(cat ${container_id})" curl -s --header Host:xhprof.${HOSTNAME} localhost 91 | | grep -q '<title>XHProf' 92 | && (echo 'XHProf install pass' && exit 0) 93 | || (echo 'XHProf install fail' && exit 1) 94 | 95 | - > 96 | sudo docker exec "$(cat ${container_id})" curl -s localhost:8025 97 | | grep -q '<title>MailHog' 98 | && (echo 'MailHog install pass' && exit 0) 99 | || (echo 'MailHog install fail' && exit 1) 100 | 101 | - > 102 | sudo docker exec "$(cat ${container_id})" curl -s --header Host:${IP} localhost 103 | | grep -q "<li>${IP} ${HOSTNAME}</li>" 104 | && (echo 'Dashboard install pass' && exit 0) 105 | || (echo 'Dashboard install fail' && exit 1) 106 | 107 | - > 108 | sudo docker exec "$(cat ${container_id})" drush @${MACHINE_NAME}.${HOSTNAME} status 109 | | grep -q 'Drupal bootstrap.*Successful' 110 | && (echo 'Drush install pass' && exit 0) 111 | || (echo 'Drush install fail' && exit 1) 112 | 113 | # Clean up 114 | - 'sudo docker stop "$(cat ${container_id})"' 115 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jeff Geerling 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a fork of the wonderful DrupalVM setup created to test the even 2 | more wonderful decoupled_blocks development. Eventually better someone 3 | smarter (or more sober) will push actual install instructions. 4 | 5 | # Quick Install 6 | 1. `cd ~/Sites` 7 | 1. `git clone git@github.com:mark-casias/decoupled-blocks-drupal-vm.git decoupled.dev` 8 | 1. `cd decoupled.dev` 9 | 1. `sudo ansible-galaxy install -r provisioning/requirements.yml --force` 10 | 1. `cp example.config.yml config.yml` 11 | 1. `cp example.drupal.make.yml drupal.make.yml` 12 | 1. `vagrant up` 13 | 1. Go get coffee. Read a book. 14 | 1. `cd drupal` 15 | 1. `drush @decoupled.dev uli` 16 | 1. Get to work. 17 | 1. profit. 18 | 19 | ### notes 20 | * If you change your path from *~/Sites*, you'll have to update the config.yml. 21 | * One day I'll add a hook to enable the modules. Till then, do it yourself. 22 | 23 | ## Drupal VM official instructions 24 | 25 | ![Drupal VM Logo](https://raw.githubusercontent.com/geerlingguy/drupal-vm/master/docs/images/drupal-vm-logo.png) 26 | 27 | [![Build Status](https://travis-ci.org/geerlingguy/drupal-vm.svg?branch=master)](https://travis-ci.org/geerlingguy/drupal-vm) [![Documentation Status](https://readthedocs.org/projects/drupal-vm/badge/?version=latest)](http://docs.drupalvm.com) 28 | 29 | [Drupal VM](http://www.drupalvm.com/) is A VM for local Drupal development, built with Vagrant + Ansible. 30 | 31 | This project aims to make spinning up a simple local Drupal test/development environment incredibly quick and easy, and to introduce new developers to the wonderful world of Drupal development on local virtual machines (instead of crufty old MAMP/WAMP-based development). 32 | 33 | It will install the following on an Ubuntu 14.04 (by default) linux VM: 34 | 35 | - Apache 2.4.x (or Nginx 1.x) 36 | - PHP 5.6.x (configurable) 37 | - MySQL 5.5.x 38 | - Drush (configurable) 39 | - Drupal 6.x, 7.x, or 8.x.x (configurable) 40 | - Optional: 41 | - Drupal Console 42 | - Varnish 4.x (configurable) 43 | - Apache Solr 4.10.x (configurable) 44 | - Node.js 0.12 (configurable) 45 | - Selenium, for testing your sites via Behat 46 | - Ruby 47 | - Memcached 48 | - Redis 49 | - XHProf, for profiling your code 50 | - XDebug, for debugging your code 51 | - Adminer, for accessing databases directly 52 | - Pimp my Log, for easy viewing of log files 53 | - MailHog, for catching and debugging email 54 | 55 | It should take 5-10 minutes to build or rebuild the VM from scratch on a decent broadband connection. 56 | 57 | Please read through the rest of this README and the [Drupal VM documentation](http://docs.drupalvm.com/) for help getting Drupal VM configured and integrated with your development workflow. 58 | 59 | ## Documentation 60 | 61 | Full Drupal VM documentation is available at http://docs.drupalvm.com/ 62 | 63 | ## Customizing the VM 64 | 65 | There are a couple places where you can customize the VM for your needs: 66 | 67 | - `config.yml`: Contains variables like the VM domain name and IP address, PHP and MySQL configuration, etc. 68 | - `drupal.make.yml`: Contains configuration for the Drupal core version, modules, and patches that will be downloaded on Drupal's initial installation (more about [Drush make files](https://www.drupal.org/node/1432374)). 69 | 70 | If you want to switch from Drupal 8 (default) to Drupal 7 or 6 on the initial install, do the following: 71 | 72 | 1. Update the Drupal `version` and `core` inside the `drupal.make.yml` file. 73 | 2. Update `drupal_major_version` inside `config.yml`. 74 | 75 | ## Quick Start Guide 76 | 77 | This Quick Start Guide will help you quickly build a Drupal 8 site on the Drupal VM using the included example Drush make file. You can also use the Drupal VM with a [Local Drupal codebase](http://docs.drupalvm.com/en/latest/deployment/local-codebase/) or even a [Drupal multisite installation](http://docs.drupalvm.com/en/latest/deployment/multisite/). 78 | 79 | ### 1 - Install Vagrant 80 | 81 | Download and install [Vagrant](https://www.vagrantup.com/downloads.html). 82 | 83 | Vagrant will automatically install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) if no providers are available (Drupal VM also works with Parallels or VMware, if you have the [Vagrant VMware integration plugin](http://www.vagrantup.com/vmware)). 84 | 85 | Notes: 86 | 87 | - **For faster provisioning** (Mac/Linux only): *[Install Ansible](http://docs.ansible.com/intro_installation.html) on your host machine, so Drupal VM can run the provisioning steps locally instead of inside the VM.* 88 | - **NFS on Linux**: *If NFS is not already installed on your host, you will need to install it to use the default NFS synced folder configuration. See guides for [Debian/Ubuntu](https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-14-04), [Arch](https://wiki.archlinux.org/index.php/NFS#Installation), and [RHEL/CentOS](https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-centos-6).* 89 | - **Versions**: *Make sure you're running the latest releases of Vagrant, VirtualBox, and Ansible—as of February 2016, Drupal VM recommends: Vagrant 1.8.1, VirtualBox 5.0.14, and Ansible 2.0.0.* 90 | 91 | ### 2 - Build the Virtual Machine 92 | 93 | 1. Download this project and put it wherever you want. 94 | 2. Make copies of both of the `example.*` files, and modify to your liking: 95 | - Copy `example.drupal.make.yml` to `drupal.make.yml`. 96 | - Copy `example.config.yml` to `config.yml`. 97 | 3. Create a local directory where Drupal will be installed and configure the path to that directory in `config.yml` (`local_path`, inside `vagrant_synced_folders`). 98 | 4. Open Terminal, `cd` to this directory (containing the `Vagrantfile` and this README file). 99 | 5. (If you have Ansible installed on Mac/Linux) Run `$ sudo ansible-galaxy install -r provisioning/requirements.yml --force`. 100 | 6. Type in `vagrant up`, and let Vagrant do its magic. 101 | 102 | 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.* 103 | 104 | ### 3 - Configure your host machine to access the VM. 105 | 106 | 1. [Edit your hosts file](http://www.rackspace.com/knowledge_center/article/how-do-i-modify-my-hosts-file), adding the line `192.168.88.88 drupalvm.dev` so you can connect to the VM. 107 | - You can have Vagrant automatically configure your hosts file if you install the `hostsupdater` plugin (`vagrant plugin install vagrant-hostsupdater`). All hosts defined in `apache_vhosts` or `nginx_hosts` will be automatically managed. The `vagrant-hostmanager` plugin is also supported. 108 | - You can also have Vagrant automatically assign an available IP address to your VM if you install the `auto_network` plugin (`vagrant plugin install vagrant-auto_network`), and set `vagrant_ip` to `0.0.0.0` inside `config.yml`. 109 | 2. Open your browser and access [http://drupalvm.dev/](http://drupalvm.dev/). The default login for the admin account is `admin` for both the username and password. 110 | 111 | ## Extra software/utilities 112 | 113 | By default, this VM includes the extras listed in the `config.yml` option `installed_extras`: 114 | 115 | installed_extras: 116 | - adminer 117 | - drupalconsole 118 | - mailhog 119 | - memcached 120 | # - nodejs 121 | - pimpmylog 122 | # - redis 123 | # - ruby 124 | # - selenium 125 | # - solr 126 | - varnish 127 | - xdebug 128 | - xhprof 129 | 130 | If you don't want or need one or more of these extras, just delete them or comment them from the list. This is helpful if you want to reduce PHP memory usage or otherwise conserve system resources. 131 | 132 | ## Using Drupal VM 133 | 134 | Drupal VM is built to integrate with every developer's workflow. Many guides for using Drupal VM for common development tasks are available on the [Drupal VM documentation site](http://docs.drupalvm.com). 135 | 136 | ## System Requirements 137 | 138 | Drupal VM runs on almost any modern computer that can run VirtualBox and Vagrant, however for the best out-of-the-box experience, it's recommended you have a computer with at least: 139 | 140 | - Intel Core processor with VT-x enabled 141 | - At least 4 GB RAM (higher is better) 142 | - An SSD (for greater speed with synced folders) 143 | 144 | ## Other Notes 145 | 146 | - To shut down the virtual machine, enter `vagrant halt` in 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 up` again), type in `vagrant destroy`. 147 | - When you rebuild the VM (e.g. `vagrant destroy` and then another `vagrant up`), make sure you clear out the contents of the `drupal` folder on your host machine, or Drupal will return some errors when the VM is rebuilt (it won't reinstall Drupal cleanly). 148 | - You can change the installed version of Drupal or drush, or any other configuration options, by editing the variables within `config.yml`. 149 | - Find out more about local development with Vagrant + VirtualBox + Ansible in this presentation: [Local Development Environments - Vagrant, VirtualBox and Ansible](http://www.slideshare.net/geerlingguy/local-development-on-virtual-machines-vagrant-virtualbox-and-ansible). 150 | - Learn about how Ansible can accelerate your ability to innovate and manage your infrastructure by reading [Ansible for DevOps](http://www.ansiblefordevops.com/). 151 | 152 | ## License 153 | 154 | This project is licensed under the MIT open source license. 155 | 156 | ## About the Author 157 | 158 | [Jeff Geerling](http://www.jeffgeerling.com/), owner of [Midwestern Mac, LLC](http://www.midwesternmac.com/), created this project in 2014 so he could accelerate his Drupal core and contrib development workflow. This project, and others like it, are also featured as examples in Jeff's book, [Ansible for DevOps](http://www.ansiblefordevops.com/). 159 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | VAGRANTFILE_API_VERSION = '2' 4 | 5 | # Cross-platform way of finding an executable in the $PATH. 6 | def which(cmd) 7 | exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] 8 | ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| 9 | exts.each do |ext| 10 | exe = File.join(path, "#{cmd}#{ext}") 11 | return exe if File.executable?(exe) && !File.directory?(exe) 12 | end 13 | end 14 | nil 15 | end 16 | 17 | def walk(obj, &fn) 18 | if obj.is_a?(Array) 19 | obj.map { |value| walk(value, &fn) } 20 | elsif obj.is_a?(Hash) 21 | obj.each_pair { |key, value| obj[key] = walk(value, &fn) } 22 | else 23 | obj = yield(obj) 24 | end 25 | end 26 | 27 | # Use config.yml for basic VM configuration. 28 | require 'yaml' 29 | dir = File.dirname(File.expand_path(__FILE__)) 30 | unless File.exist?("#{dir}/config.yml") 31 | raise 'Configuration file not found! Please copy example.config.yml to config.yml and try again.' 32 | end 33 | vconfig = YAML.load_file("#{dir}/config.yml") 34 | 35 | # Replace jinja variables in config. 36 | vconfig = walk(vconfig) do |value| 37 | while value.is_a?(String) && value.match(/{{ .* }}/) 38 | value = value.gsub(/{{ (.*?) }}/) { vconfig[Regexp.last_match(1)] } 39 | end 40 | value 41 | end 42 | 43 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 44 | # Networking configuration. 45 | config.vm.hostname = vconfig['vagrant_hostname'] 46 | if vconfig['vagrant_ip'] == '0.0.0.0' && Vagrant.has_plugin?('vagrant-auto_network') 47 | config.vm.network :private_network, ip: vconfig['vagrant_ip'], auto_network: true 48 | else 49 | config.vm.network :private_network, ip: vconfig['vagrant_ip'] 50 | end 51 | 52 | if !vconfig['vagrant_public_ip'].empty? && vconfig['vagrant_public_ip'] == '0.0.0.0' 53 | config.vm.network :public_network 54 | elsif !vconfig['vagrant_public_ip'].empty? 55 | config.vm.network :public_network, ip: vconfig['vagrant_public_ip'] 56 | end 57 | 58 | # SSH options. 59 | config.ssh.insert_key = false 60 | config.ssh.forward_agent = true 61 | 62 | # Vagrant box. 63 | config.vm.box = vconfig['vagrant_box'] 64 | 65 | # If a hostsfile manager plugin is installed, add all server names as aliases. 66 | aliases = [] 67 | if vconfig['drupalvm_webserver'] == 'apache' 68 | vconfig['apache_vhosts'].each do |host| 69 | aliases.push(host['servername']) 70 | aliases.concat(host['serveralias'].split) if host['serveralias'] 71 | end 72 | else 73 | vconfig['nginx_hosts'].each do |host| 74 | aliases.concat(host['server_name'].split) 75 | aliases.concat(host['server_name_redirect'].split) if host['server_name_redirect'] 76 | end 77 | end 78 | aliases = aliases.uniq - [config.vm.hostname, vconfig['vagrant_ip']] 79 | 80 | if Vagrant.has_plugin?('vagrant-hostsupdater') 81 | config.hostsupdater.aliases = aliases 82 | elsif Vagrant.has_plugin?('vagrant-hostmanager') 83 | config.hostmanager.enabled = true 84 | config.hostmanager.manage_host = true 85 | config.hostmanager.aliases = aliases 86 | end 87 | 88 | # Synced folders. 89 | vconfig['vagrant_synced_folders'].each do |synced_folder| 90 | options = { 91 | type: synced_folder['type'], 92 | rsync__auto: 'true', 93 | rsync__exclude: synced_folder['excluded_paths'], 94 | rsync__args: ['--verbose', '--archive', '--delete', '-z', '--chmod=ugo=rwX'], 95 | id: synced_folder['id'], 96 | create: synced_folder.include?('create') ? synced_folder['create'] : false, 97 | mount_options: synced_folder.include?('mount_options') ? synced_folder['mount_options'] : [] 98 | } 99 | if synced_folder.include?('options_override') 100 | options = options.merge(synced_folder['options_override']) 101 | end 102 | config.vm.synced_folder synced_folder['local_path'], synced_folder['destination'], options 103 | end 104 | 105 | # Allow override of the default synced folder type. 106 | config.vm.synced_folder '.', '/vagrant', type: vconfig.include?('vagrant_synced_folder_default_type') ? vconfig['vagrant_synced_folder_default_type'] : 'nfs' 107 | 108 | # Provisioning. Use ansible if it's installed, JJG-Ansible-Windows if not. 109 | if which('ansible-playbook') 110 | config.vm.provision 'ansible' do |ansible| 111 | ansible.playbook = "#{dir}/provisioning/playbook.yml" 112 | end 113 | else 114 | config.vm.provision 'shell' do |sh| 115 | sh.path = "#{dir}/provisioning/JJG-Ansible-Windows/windows.sh" 116 | sh.args = '/provisioning/playbook.yml' 117 | end 118 | end 119 | # ansible_local provisioner is broken in Vagrant < 1.8.2. 120 | # else 121 | # config.vm.provision "ansible_local" do |ansible| 122 | # ansible.playbook = "provisioning/playbook.yml" 123 | # ansible.galaxy_role_file = "provisioning/requirements.yml" 124 | # end 125 | # end 126 | 127 | # VMware Fusion. 128 | config.vm.provider :vmware_fusion do |v, override| 129 | # HGFS kernel module currently doesn't load correctly for native shares. 130 | override.vm.synced_folder '.', '/vagrant', type: 'nfs' 131 | 132 | v.gui = false 133 | v.vmx['memsize'] = vconfig['vagrant_memory'] 134 | v.vmx['numvcpus'] = vconfig['vagrant_cpus'] 135 | end 136 | 137 | # VirtualBox. 138 | config.vm.provider :virtualbox do |v| 139 | v.linked_clone = true if Vagrant::VERSION =~ /^1.8/ 140 | v.name = vconfig['vagrant_hostname'] 141 | v.memory = vconfig['vagrant_memory'] 142 | v.cpus = vconfig['vagrant_cpus'] 143 | v.customize ['modifyvm', :id, '--natdnshostresolver1', 'on'] 144 | v.customize ['modifyvm', :id, '--ioapic', 'on'] 145 | end 146 | 147 | # Parallels. 148 | config.vm.provider :parallels do |p, override| 149 | override.vm.box = vconfig['vagrant_box'] 150 | p.name = vconfig['vagrant_hostname'] 151 | p.memory = vconfig['vagrant_memory'] 152 | p.cpus = vconfig['vagrant_cpus'] 153 | p.update_guest_tools = true 154 | end 155 | 156 | # Set the name of the VM. See: http://stackoverflow.com/a/17864388/100134 157 | config.vm.define vconfig['vagrant_machine_name'] 158 | 159 | # Allow an untracked Vagrantfile to modify the configurations 160 | eval File.read 'Vagrantfile.local' if File.exist?('Vagrantfile.local') 161 | end 162 | -------------------------------------------------------------------------------- /docs/deployment/drush-make.md: -------------------------------------------------------------------------------- 1 | Drupal VM is configured by default to use a Drush make file to build a Drupal site on the VM inside `/var/www/drupalvm/drupal` (in a folder that's synced to your local machine, so you can work with the Drupal codebase either locally or inside the VM). 2 | 3 | You can use any make file you want, just copy it or symlink it into the root of the Drupal VM folder with the filename `drupal.make.yml`. You can also set a separate path to the makefile using the `drush_makefile_path` variable. 4 | 5 | Leave the rest of the settings in `config.yml` as defaults from `example.config.yml`, or tweak the settings as you'd like, then run `vagrant up` as in the Quick Start Guide. Within a few minutes, you should have your site running and available at the `drupal_domain` configured in `config.yml`. -------------------------------------------------------------------------------- /docs/deployment/local-codebase.md: -------------------------------------------------------------------------------- 1 | If you already have a Drupal codebase on your host machine (e.g. in `~/Sites/my-drupal-site`), and don't want or need to build your Drupal site with a Drush make file, make the following changes to `config.yml` before building Drupal VM: 2 | 3 | ## Sync your Drupal codebase to the VM 4 | 5 | Update the `vagrant_synced_folders` configuration to sync your local Drupal codebase to a folder within the machine: 6 | 7 | ```yaml 8 | vagrant_synced_folders: 9 | - local_path: ~/Sites/my-drupal-site 10 | destination: /var/www/my-drupal-site 11 | type: nfs 12 | ``` 13 | 14 | ## Disable the Drush make build and site install 15 | 16 | Set `build_makefile` and `install_site` to `false`: 17 | 18 | ```yaml 19 | build_makefile:: false 20 | ... 21 | install_site: false 22 | ``` 23 | 24 | If you aren't copying back a database, and want to have Drupal VM run `drush si` for your Drupal site, you can leave `install_site` set to `true` and it will run a site install on your Drupal codebase using the `drupal_*` config variables. 25 | 26 | ## Update `apache_vhosts` 27 | 28 | Add your site to `apache_vhosts`, setting the `documentroot` to the same value as the `destination` of the synced folder you configured earlier: 29 | 30 | ```yaml 31 | apache_vhosts: 32 | - servername: "local.my-drupal-site.com" 33 | documentroot: "/var/www/my-drupal-site" 34 | extra_parameters: | 35 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}" 36 | ``` 37 | 38 | ## Update MySQL info 39 | 40 | If you have your Drupal site configured to use a special database and/or user/password for local development (e.g. through a `settings.local.php` file), you can update the values for `mysql_databases` and `mysql_users` as well. 41 | 42 | ## Build the VM, import your database 43 | 44 | Run `vagrant up` to build the VM with your codebase synced into the proper location. Once the VM is created, you can [connect to the MySQL database](../extras/mysql.md) and import your site's database to the Drupal VM, or use a command like `drush sql-sync` to copy a database from another server. 45 | -------------------------------------------------------------------------------- /docs/deployment/multisite.md: -------------------------------------------------------------------------------- 1 | For multisite installations, make the changes outlined in the [Local Drupal codebase](local-codebase.md) guide, but, using the `apache_vhosts` variable, configure as many domains pointing to the same docroot as you need: 2 | 3 | ```yaml 4 | apache_vhosts: 5 | - servername: "local.my-drupal-site.com" 6 | documentroot: "/var/www/my-drupal-site" 7 | extra_parameters: | 8 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}" 9 | - servername: "local.second-drupal-site.com" 10 | documentroot: "/var/www/my-drupal-site" 11 | extra_parameters: | 12 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}" 13 | - servername: "local.third-drupal-site.com" 14 | documentroot: "/var/www/my-drupal-site" 15 | extra_parameters: | 16 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}" 17 | ``` 18 | 19 | If you need additional databases and database users, add them to the list of `mysql_databases` and `mysql_users`: 20 | 21 | ```yaml 22 | mysql_databases: 23 | - name: drupal 24 | encoding: utf8 25 | collation: utf8_general_ci 26 | - name: drupal_two 27 | encoding: utf8 28 | collation: utf8_general_ci 29 | 30 | mysql_users: 31 | - name: drupal 32 | host: "%" 33 | password: drupal 34 | priv: "drupal.*:ALL" 35 | - name: drupal-two 36 | host: "%" 37 | password: drupal-two 38 | priv: "drupal_two.*:ALL" 39 | ``` -------------------------------------------------------------------------------- /docs/extras/behat.md: -------------------------------------------------------------------------------- 1 | Behat is an open source behavior-driven development tool for PHP. You can use Behat to build and run automated tests for site functionality on your Drupal sites, and Drupal VM has excellent built-in support for Behat, using Selenium to run tests in a headless instance of FireFox. 2 | 3 | ## Getting Started - Installing Prerequisites 4 | 5 | To make Behat available globally for all your projects within Drupal VM, make the following changes inside `config.yml`, then run `vagrant up` (or `vagrant provision` if the VM is already built): 6 | 7 | ```yaml 8 | # Make sure selenium is not commented out in the list of installed_extras: 9 | installed_extras: 10 | [...] 11 | - selenium 12 | [...] 13 | 14 | # Make sure the following four packages are in composer_global_packages: 15 | composer_global_packages: 16 | - { name: behat/mink, release: '1.5.*@stable' } 17 | - { name: behat/mink-goutte-driver, release: '*' } 18 | - { name: behat/mink-selenium2-driver, release: '*' } 19 | - { name: drupal/drupal-extension, release: '*' } 20 | ``` 21 | 22 | After Drupal VM is finished provisioning, you should be able to log in and run the following command to make sure Behat is installed correctly: 23 | 24 | ``` 25 | $ behat --version 26 | behat version 3.0.15 27 | ``` 28 | 29 | _You can also include the `behat/*` and `drupal/drupal-extension` directly in your project's `composer.json` file, and install the dependencies per-project. Either option (installing globally, like above, or installing per-project) is perfectly acceptable._ 30 | 31 | ## Setting up Behat for your project 32 | 33 | Using the default Drupal site as an example (it's installed in `/var/www/drupalvm/drupal` by default, and is shared to `~/Sites/drupalvm/drupal` on your host machine), the following steps will help you get your first Behat tests up and running! 34 | 35 | 1. Create a `behat.yml` file inside the docroot of your site (e.g. create this file alongside the rest of the Drupal codebase at `/var/www/drupalvm/drupal/behat.yml`), with the following contents: 36 | 37 | default: 38 | suites: 39 | web_features: 40 | paths: [ %paths.base%/features/web ] 41 | contexts: 42 | - WebContext 43 | - Drupal\DrupalExtension\Context\DrupalContext 44 | - Drupal\DrupalExtension\Context\MinkContext 45 | - Drupal\DrupalExtension\Context\MessageContext 46 | - Drupal\DrupalExtension\Context\DrushContext 47 | extensions: 48 | Behat\MinkExtension: 49 | goutte: ~ 50 | javascript_session: selenium2 51 | selenium2: 52 | wd_host: http://drupalvm.dev:4444/wd/hub 53 | base_url: http://drupalvm.dev 54 | Drupal\DrupalExtension: 55 | blackbox: ~ 56 | api_driver: 'drupal' 57 | drupal: 58 | drupal_root: '/var/www/drupalvm/drupal' 59 | region_map: 60 | content: "#content" 61 | 62 | 2. Log into Drupal VM with `vagrant ssh`, change directory to the Drupal site root (`cd /var/www/drupalvm/drupal`), then run `behat --init` to initialize the `features` folder where you will place test cases. 63 | 3. From either inside the VM or on the host machine, open up the new `features/web` folder Behat just created. Inside _that_ folder, create `HomeContent.feature` with the following contents: 64 | 65 | Feature: Test DrupalContext 66 | In order to prove the Behat is working correctly in Drupal VM 67 | As a developer 68 | I need to run a simple interface test 69 | 70 | Scenario: Viewing content in a region 71 | Given I am on the homepage 72 | Then I should see "No front page content has been created yet" in the "content" 73 | 74 | 4. Now, inside Drupal VM, change directory to `/var/www/drupalvm/drupal` again, and run the command `behat` (which runs all the tests you've created—which should just be one so far). 75 | 76 | If everything was done correctly, you should see: 77 | 78 | ```console 79 | $ behat 80 | Feature: Test DrupalContext 81 | In order to prove the Behat is working correctly in Drupal VM 82 | As a developer 83 | I need to run a simple interface test 84 | 85 | Scenario: Viewing content in a region # features/drupal/HomeContent.feature:6 86 | Given I am on the homepage # Drupal\DrupalExtension\Context\MinkContext::iAmOnHomepage() 87 | Then I should see "No front page content has been created yet" in the "content" # Drupal\DrupalExtension\Context\MinkContext::assertRegionText() 88 | 89 | 1 scenario (1 passed) 90 | 2 steps (2 passed) 91 | 0m0.56s (26.48Mb) 92 | ``` 93 | 94 | Hooray! Now you're ready to get started testing ALL THE THINGS! Check out the following resources for more information about Behat and Drupal: 95 | 96 | - [Behat 3.0 Documentation](http://behat.readthedocs.org/en/v3.0/) 97 | - [Drupal Extension Documentation](https://behat-drupal-extension.readthedocs.org/en/3.0/) 98 | -------------------------------------------------------------------------------- /docs/extras/drupal-console.md: -------------------------------------------------------------------------------- 1 | [Drupal Console](https://drupalconsole.com/) is a modern CLI for interacting with Drupal and scaffolding a site. It works only with Drupal 8+, and is built on top of the Symfony Console component. 2 | 3 | Drupal VM will automatically install Drupal Console if you install Drupal 8 or later in your VM (this is based on the value of the `drupal_major_version` variable inside `config.yml`. 4 | 5 | To use Drupal Console with a Drupal 8 site (in this case, using the default configuration that ships with Drupal VM): 6 | 7 | 1. Log into the VM with `vagrant ssh`. 8 | 2. Change directory to the Drupal site's document root: `cd /var/www/drupalvm/drupal`. 9 | 3. Use Drupal console (e.g. `drupal cache:rebuild all`). 10 | 11 | You should see an output like: 12 | 13 | ``` 14 | vagrant@drupalvm:/var/www/drupalvm/drupal$ drupal cache:rebuild all 15 | 16 | [+] Rebuilding cache(s), wait a moment please. 17 | [+] Done clearing cache(s). 18 | 19 | The command was executed successfully! 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/extras/drush.md: -------------------------------------------------------------------------------- 1 | If you have Drush installed on your host workstation, and would like to interact with a Drupal site running inside Drupal VM, there are drush aliases automatically created by Drupal VM for each of the virtual hosts you have configured. 2 | 3 | With the example configuration, you can manage the example Drupal site using the Drush alias `@drupalvm.dev`. For example, to check if Drush can connect to the site in Drupal VM, run: 4 | 5 | ``` 6 | $ drush @drupalvm.dev status 7 | Drupal version : 8.0.0-dev 8 | Site URI : drupalvm.dev 9 | Database driver : mysql 10 | Database hostname : localhost 11 | Database port : 12 | Database username : drupal 13 | Database name : drupal 14 | Database : Connected 15 | Drupal bootstrap : Successful 16 | Drupal user : Anonymous 17 | Default theme : bartik 18 | Administration theme : seven 19 | PHP executable : /usr/bin/php 20 | PHP configuration : /etc/php5/cli/php.ini 21 | PHP OS : Linux 22 | Drush script : /usr/local/share/drush/drush.php 23 | Drush version : 7.0-dev 24 | Drush temp directory : /tmp 25 | Drush configuration : 26 | Drush alias files : 27 | Drupal root : /var/www/drupalvm/drupal 28 | Site path : sites/default 29 | File directory path : sites/default/files 30 | Temporary file : /tmp 31 | directory path 32 | Active config path : [...] 33 | Staging config path : [...] 34 | ``` 35 | 36 | Drupal VM automatically generates a drush alias file in `~/.drush/drupalvm.aliases.drushrc.php` with an alias for every site you have defined in the `apache_vhosts` variable. 37 | 38 | You can disable Drupal VM's automatic Drush alias file management if you want to manage drush aliases on your own. Just set the `configure_local_drush_aliases` variable in `config.yml` to `false`. -------------------------------------------------------------------------------- /docs/extras/mailhog.md: -------------------------------------------------------------------------------- 1 | By default, Drupal VM redirects all PHP emails to [MailHog](https://github.com/mailhog/MailHog) (instead of sending them to the outside world). You can access the MailHog UI at `http://drupalvm.dev:8025/` (or whatever domain you have configured in `config.yml`). 2 | 3 | You can override the default behavior of redirecting email to MailHog by editing or removing the `php_sendmail_path` inside `config.yml`, and you can choose to not install MailHog at all by removing it from `installed_extras` in `config.yml`. -------------------------------------------------------------------------------- /docs/extras/mariadb.md: -------------------------------------------------------------------------------- 1 | Since Drupal VM is built in a modular fashion, and the upstream Ansible Role that installs and configures MySQL is built in a way that works with any MySQL-compatible replacement, you can easily swap out MySQL for MariaDB. 2 | 3 | The simplest way is to add the following lines after the `# MySQL Configuration.` line in `config.yml`: 4 | 5 | ```yaml 6 | mysql_packages: 7 | - mariadb-client 8 | - mariadb-server 9 | - python-mysqldb 10 | ``` 11 | 12 | This set of packages works out of the box with the default Ubuntu 14.04 installation that comes with Drupal VM. 13 | 14 | Alternatively, if you want to use RedHat 7 or CentOS 7 instead of Ubuntu, you can set the following variables to install and configure MariaDB instead of MySQL: 15 | 16 | ```yaml 17 | mysql_packages: 18 | - mariadb 19 | - mariadb-server 20 | - mariadb-libs 21 | - MySQL-python 22 | - perl-DBD-MySQL 23 | mysql_daemon: mariadb 24 | mysql_socket: /var/lib/mysql/mysql.sock 25 | mysql_log_error: /var/log/mariadb/mariadb.log 26 | mysql_syslog_tag: mariadb 27 | mysql_pid_file: /var/run/mariadb/mariadb.pid 28 | ``` -------------------------------------------------------------------------------- /docs/extras/mysql.md: -------------------------------------------------------------------------------- 1 | By default, this VM is set up so you can manage MySQL databases on your own. The default root MySQL user credentials are `root` for username and password, but you can change the password via `config.yml` (changing the `mysql_root_password` variable). I use [Sequel Pro](http://www.sequelpro.com/) (Mac-only) to connect to and manage databases, and Drush to sync databases (sometimes I'll just do a dump and import, but Drush is usually quicker, and is easier to do over and over again when you need it). 2 | 3 | ## Connect using Adminer 4 | 5 | If you have `adminer` listed as one of the `installed_extras` inside `config.yml`, you can use Adminer's web-based interface to interact with databases. With Drupal VM running, visit `http://adminer.drupalvm.dev/`, and log in with `root` as the username and the password you set in `config.yml` (`mysql_root_password`). Leave the "Server" field blank. The "Database" field is optional. 6 | 7 | More about how to use Adminer: [Adminer website](http://www.adminer.org/). 8 | 9 | ## Connect using Sequel Pro (or a similar client): 10 | 11 | 1. Use the SSH connection type. 12 | 2. Set the following options: 13 | - MySQL Host: `127.0.0.1` 14 | - Username: `root` 15 | - Password: `root` (or the password configured in `config.yml`) 16 | - SSH Host: `192.168.88.88` (or the IP configured in `config.yml`) 17 | - SSH User: `vagrant` 18 | - SSH Key: (browse to your `~/.vagrant.d/` folder and choose `insecure_private_key`) 19 | 20 | You should be able to connect as the root user and add, manage, and remove databases and users. 21 | -------------------------------------------------------------------------------- /docs/extras/nodejs.md: -------------------------------------------------------------------------------- 1 | Node.js is used for many different purposes, but with Drupal, it is most often used as part of a toolset for Front End development or certain CI tasks. 2 | 3 | Drupal VM includes built-in support for Node.js—all you need to do is make sure `nodejs` is listed in the list of `installed_extras` inside `config.yml` before your provision Drupal VM. 4 | 5 | ## Choosing a version of Node.js 6 | 7 | You can choose a version of Node.js to install using the `nodejs_version` variable in `config.yml`. See the [`geerlingguy.nodejs` Ansible role's README](https://github.com/geerlingguy/ansible-role-nodejs#readme) for all the currently-available versions for your OS. 8 | 9 | ```yaml 10 | nodejs_version: "0.12" 11 | ``` 12 | 13 | ## Installing global packages via NPM 14 | 15 | To install packages globally, you can add them to the list of `nodejs_npm_global_packages` in `config.yml`. As an example, many developers use `phantomjs` as a ghost web driver for Behat tests inside Drupal VM. To install it globally, add it to the list: 16 | 17 | ```yaml 18 | nodejs_npm_global_packages: 19 | - name: phantomjs 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/extras/pimpmylog.md: -------------------------------------------------------------------------------- 1 | [Pimp my Log](http://pimpmylog.com/) is a PHP-based web GUI for viewing log files on a given server. By default, it is installed on Drupal VM, and you can access it at the URL `http://pimpmylog.drupalvm.dev/` (as long as you have a hosts entry for that URL pointing at Drupal VM's IP address!). 2 | 3 | By default, it will find the default Apache 2 `access.log` and `error.log` files, but it will not find other logs, like MySQL or extra Apache virtualhost logs. 4 | 5 | When configuring Pimp my Log (on the first visit to the `pimpmylog.drupalvm.dev` URL), you can add extra paths in the UI, or you can add them after the fact by manually editing the configuration file, which by default is stored at `/usr/share/php/pimpmylog/config.user.php`. You can also delete that file and re-configure Pimp my Log via the web UI. 6 | 7 | Some log files you may be interested in monitoring: 8 | 9 | - `/var/log/apache2/access.log` 10 | - `/var/log/apache2/error.log` (this log will show Apache and PHP notices/warnings/errors) 11 | - `/var/log/apache2/other_vhosts_access.log` 12 | - `/var/log/mysql.err` (MySQL error log) 13 | - `/var/log/mysql-slow.log` (MySQL slow query log) 14 | - `/var/log/syslog` (enable the Drupal syslog module to route watchdog log entries to this file) 15 | 16 | For MySQL logs, you might want to read through the PML docs on [MySQL](http://support.pimpmylog.com/kb/softwares/mysql). 17 | 18 | It might be necessary to grant read permissions to the other group (e.g. `chmod o+r /var/log/mysql.err`) on some log files in order for Pimp My Log to be able to parse them. 19 | -------------------------------------------------------------------------------- /docs/extras/scripts.md: -------------------------------------------------------------------------------- 1 | Drupal VM allows you to run extra shell scripts at the end of the provisioning process, in case you need to do extra setup, further configure the VM, or install extra software outside the purview of Drupal VM. 2 | 3 | To use an extra script, configure the path to the script (relative to `provisioning/playbook.yml`) in `config.yml`: 4 | 5 | ```yaml 6 | post_provision_scripts: 7 | - "../scripts/post-provision.sh" 8 | ``` 9 | 10 | The above example results in a `post-provision.sh` script running after the main Drupal VM setup is complete. Post provision scripts run after the first `vagrant up`, and then any time you run Vagrant provisioning (e.g. `vagrant provision` or `vagrant up --provision`). 11 | 12 | You can define as many scripts as you would like, and any arguments after the path will be passed to the shell script itself (e.g. `"- "../scripts/setup-paths.sh --option"`). 13 | 14 | Place your post-provision scripts inside a `scripts` directory in the root of your Drupal VM project directory; this directory is gitignored, so you can continue to update Drupal VM without overwriting your scripts. 15 | -------------------------------------------------------------------------------- /docs/extras/solr.md: -------------------------------------------------------------------------------- 1 | Drupal VM makes using Apache Solr easy; just make sure `solr` is in the list of `installed_extras` in your `config.yml`, and when you build Drupal VM, the latest version of Apache Solr will be installed. 2 | 3 | Inside of Drupal, you can use any of the available Apache Solr integration modules (e.g. [Apache Solr Search](https://www.drupal.org/project/apachesolr) or [Search API Solr Search](https://www.drupal.org/project/search_api_solr)), and when you configure the modules, follow the installation instructions included with the module. 4 | 5 | The URL to connect to the local solr server (assuming you're using the default `solr_port` of 8983) from Drupal is: 6 | 7 | http://localhost:8983/solr/collection1 8 | 9 | This will connect to the default search core (`collection1`) set up by Solr. If you are using a multisite installation and want to have a search core per Drupal site, you can add more cores through Apache Solr's admin interface (visit `http://drupalvm.dev:8983/solr/`), then connect to each core by adding the core name to the end of the above URL (e.g. `core2` would be `http://localhost:8983/solr/core2`). 10 | 11 | ## Configuring the Solr search core for Drupal 12 | 13 | Before Drupal content can be indexed correctly into Apache Solr, you will need to copy the Drupal Apache Solr Search or Search API Apache Solr configuration into place, and restart Apache Solr. Drupal VM comes with an example post provision script for automating this. Simply add it to `post_provision_scripts`: 14 | 15 | ```yaml 16 | post_provision_scripts: 17 | - "../examples/scripts/configure-solr.sh" 18 | ``` 19 | 20 | ## Extra Solr configuration 21 | 22 | You can add extra configuration for Solr, like the minimum and maximum memory allocation for the JVM (`solr_xms` and `solr_xmx`), and even the `solr_version`, by setting the appropriate variables inside `config.yml` before you build Drupal VM. -------------------------------------------------------------------------------- /docs/extras/ssl.md: -------------------------------------------------------------------------------- 1 | To enable SSL support for you virtual hosts you first need a certificate file. You can generate a self-signed certificate with a command like 2 | 3 | openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout example.key -out example.crt 4 | 5 | Place the files in your project directory and add the following to your `config.yml`. 6 | 7 | ```yaml 8 | apache_vhosts_ssl: 9 | - servername: "{{ drupal_domain }}" 10 | documentroot: "{{ drupal_core_path }}" 11 | certificate_file: "/vagrant/example.crt" 12 | certificate_key_file: "/vagrant/example.key" 13 | extra_parameters: | 14 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}" 15 | ``` 16 | 17 | _If you're using an actual production certificate you should of course **NOT** track it in git but transfer it to the VM before running `vagrant provision`_ 18 | 19 | For a list of all configuration options see the [`geerlingguy.apache` Ansible role's README](https://github.com/geerlingguy/ansible-role-apache#readme). 20 | 21 | ### Using Ubuntu's snakeoil certificate 22 | 23 | If you are using Ubuntu as your base OS and you want to get started quickly with a local development environment you can use the snakeoil certificate that is already generated. 24 | 25 | ```yaml 26 | apache_vhosts_ssl: 27 | - servername: "{{ drupal_domain }}" 28 | documentroot: "{{ drupal_core_path }}" 29 | certificate_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem" 30 | certificate_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key" 31 | extra_parameters: | 32 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}" 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/extras/syncing-folders.md: -------------------------------------------------------------------------------- 1 | You can share folders between your host computer and the VM in a variety of ways; the most commonly-used method is an NFS share. If you use Windows and encounter any problems with NFS, try switching to `smb`. The `example.config.yml` file contains an example `nfs` share that would sync the folder `~/Sites/drupalvm` on your host into the `/var/www/drupalvm` folder on Drupal VM. 2 | 3 | If you want to use a different synced folder method (e.g. `smb`), you can change `type` to: 4 | 5 | ```yaml 6 | vagrant_synced_folders: 7 | - local_path: ~/Sites/drupalvm 8 | destination: /var/www/drupalvm 9 | type: smb 10 | ``` 11 | 12 | You can add as many synced folders as you'd like, and you can configure [any type of share](https://www.vagrantup.com/docs/synced-folders/index.html) supported by Vagrant; just add another item to the list of `vagrant_synced_folders`. 13 | 14 | ## Options 15 | 16 | The synced folder options exposed are `type`, `excluded_paths` (when using rsync), `id`, `create` and `mount_options`. Besides these there are some sane defaults set when using rsync. For example all files synced with rsync will be writable by everyone, thus allowing the web server to create files. 17 | 18 | ### Overriding defaults 19 | 20 | If you feel the need to fine-tune some of the options not exposed, the entire options hash passed to Vagrant can be overriden using `options_override`. 21 | 22 | The merge of the default options and `options_override` is shallow, so you can use it to remove flags from eg. `rsync__args`. 23 | 24 | One scenario where this might be useful is when you are moving generated code from the virtual machine back to your local machine and you want the files to have appropriate permissions instead of the default 666/777. 25 | 26 | ```yaml 27 | options_override: 28 | # Disable the default recursive chown so that the files/ folder won't be affected 29 | rsync__chown: false 30 | rsync__args: [ 31 | "--verbose", "--archive", "--delete", 32 | "--chmod=gu=rwX,o=rX", # 664 for files, 775 for directories 33 | "--owner", "--group", # required for the following command 34 | "--usermap=*:vagrant", "--groupmap=*:www-data" 35 | ] 36 | ``` 37 | 38 | ## Synced Folder Performance 39 | 40 | Using different synced folder mechanisms can have a dramatic impact on your Drupal site's performance. Please read through the following blog posts for a thorough overview of synced folder performance: 41 | 42 | - [Comparing filesystem performance in Virtual Machines](http://mitchellh.com/comparing-filesystem-performance-in-virtual-machines) 43 | - [NFS, rsync, and shared folder performance in Vagrant VMs](http://www.jeffgeerling.com/blogs/jeff-geerling/nfs-rsync-and-shared-folder) 44 | 45 | Generally speaking: 46 | 47 | - NFS offers a decent tradeoff between performance and ease of use 48 | - SMB offers a similar tradeoff, but is a bit slower than NFS 49 | - Rsync offers the best performance inside the VM, but sync is currently one-way-only (from host to VM), which can make certain development workflows burdensome 50 | - Native shared folders offer abysmal performance; only use this mechanism as a last resort! 51 | 52 | If you are using rsync, it is advised to exclude certain directories so that they aren't synced. These include version control directories, database exports and Drupal's files directory. 53 | 54 | ```yaml 55 | vagrant_synced_folders: 56 | - local_path: ~/Sites/drupalvm/drupal 57 | destination: /var/www/drupalvm 58 | type: rsync 59 | excluded_paths: 60 | - drupal/private 61 | - drupal/public/.git 62 | - drupal/public/sites/default/files 63 | - drupal/tmp 64 | ``` 65 | 66 | This example assumes that you have Drupal in a directory called `drupal/public`. 67 | 68 | ## Synced Folder Troubleshooting 69 | 70 | There are a number of issues people encounter with synced folders from time to time. The most frequent issues are listed below with possible solutions: 71 | 72 | ### Using Native Synced Folders 73 | 74 | You can use a native synced folder, which should work pretty flawlessly on any platform, but with a potential serious performance downside (compared to other synced folder methods). Just set `type` to `""`, and you can even put the synced folder inside the drupal-vm folder using a relative path, like: 75 | 76 | ```yaml 77 | vagrant_synced_folders: 78 | - local_path: docroot 79 | destination: /var/www/docroot 80 | type: "" 81 | create: true 82 | ``` 83 | 84 | See [this issue](https://github.com/geerlingguy/drupal-vm/issues/67) for more information. 85 | 86 | ### VirtualBox Guest Additions out of date 87 | 88 | If you get errors when running `vagrant up` stating that your guest additions are out of date, you can fix this easily by installing the `vagrant-vbguest` plugin. Run the following command in the drupal-vm folder: `vagrant plugin install vagrant-vbguest`. 89 | 90 | Otherwise, you will need to make sure you're using the officially supported `geerlingguy/ubuntu1404` box, which should _generally_ have the latest (or near-latest) guest additions installed. If not, please open an issue in the upstream project for building the base box: [`packer-ubuntu-1404`](https://github.com/geerlingguy/packer-ubuntu-1404). 91 | 92 | ### Permissions-related errors 93 | 94 | If you're encountering errors where Drupal or some other software inside the VM is having permissions issues creating or deleting files inside a synced folder, you might need to either make sure the file permissions are correct on your host machine (if a folder is not readable by you, it probably also won't be readable when mounted via NFS!), or add extra configuration to the synced folders item inside the Vagrantfile (if using a sync method like `rsync`): 95 | 96 | ``` 97 | owner: "vagrant", 98 | group: "www-data", 99 | mount_options: ["dmode=775,fmode=664"] 100 | ``` 101 | 102 | See [this issue](https://github.com/geerlingguy/drupal-vm/issues/66) for more details. 103 | 104 | ### Other NFS-related errors 105 | 106 | If you're having other weird issues, and none of the above fixes helps, you might want to try a different synced folder method (see top of this page), or something like File Conveyor or a special rsync setup (see [here](http://wolfgangziegler.net/auto-rsync-local-changes-to-remote-server#comments) for some examples). -------------------------------------------------------------------------------- /docs/extras/varnish.md: -------------------------------------------------------------------------------- 1 | [Varnish](https://www.varnish-software.com/) is an advanced reverse proxy and HTTP accelerator. At a basic level, it can act as a lightweight, very fast, and highly configurable static cache in front of your Drupal site. It also works as a load balancer and has some other tricks up it's sleeve, but for Drupal VM's purposes, you can think of it as a simple way to supercharge your site via proxy caching. 2 | 3 | To enable Varnish, make sure `varnish` is in the list of your `installed_extras` in `config.yml`, and run `vagrant provision`. 4 | 5 | There are a few varnish configuration variables further down in `example.config.yml` that you may wish to configure. You can use your own `.vcl` file template (instead of the generic Drupal 7-focused generic one) by editing the `varnish_default_vcl_template_path`, and you can use a different port for Varnish by changing `varnish_listen_port`. 6 | 7 | If you'd like to use Varnish on port 80, and switch Apache to a different backend port, you can do so pretty easily; just make sure you have the following values set in your `config.yml` file, and run `vagrant provision` to have Ansible make the necessary changes: 8 | 9 | ```yaml 10 | apache_listen_port: "81" 11 | 12 | varnish_listen_port: "80" 13 | varnish_default_backend_port: "81" 14 | ``` 15 | 16 | ## Required Drupal Changes 17 | 18 | In order for Varnish to actually do anything helpful (instead of just pass through requests and responses to/from the Apache backend), you need to set a few settings in Drupal: 19 | 20 | 21 | - On the `/admin/config/development/performance` page: 22 | - Check the 'Cache pages for anonymous users' setting (if it's not already enabled). 23 | - Set both the 'Minimum Cache Lifetime' and 'Expiration of cached pages' values to something reasonable (e.g. 5, 10, or 15 minutes—or much more if you don't update the content on the site much!). 24 | 25 | You will also need to make a few small changes to your site's `settings.php` configuration to make Drupal work correctly behind a reverse proxy like Varnish: 26 | 27 | ```php 28 | $conf['reverse_proxy'] = TRUE; 29 | $conf['reverse_proxy_addresses'] = array('127.0.0.1'); 30 | ``` 31 | 32 | If you don't set these values, Drupal will think all requests are coming from `127.0.0.1`. There are other settings you can change to make Drupal not store copies of cached pages in the Database (since Varnish is caching everything, this is redundant), but those other settings are not covered here. -------------------------------------------------------------------------------- /docs/extras/xdebug.md: -------------------------------------------------------------------------------- 1 | XDebug is a useful tool for debugging PHP applications, but it uses extra memory and CPU for every request, so is disabled by default. 2 | 3 | To enable XDebug, do the following in `config.yml`: 4 | 5 | - Change `php_xdebug_default_enable` (and, optionally, `php_xdebug_coverage_enable` to get code coverage reports) to `1` 6 | - Make sure `xdebug` is in the list of `installed_extras` 7 | 8 | If you don't need to use XDebug, you can comment it out or remove it from `installed_extras` before you `vagrant up` Drupal VM. 9 | 10 | ## PHPStorm and XDebug with Drupal VM 11 | 12 | To use XDebug with PHPStorm, change the `php_xdebug_idekey` variable as shown below in `config.yml`, and then run `vagrant provision` to reconfigure the VM: 13 | 14 | ```yaml 15 | php_xdebug_idekey: PHPSTORM 16 | ``` 17 | 18 | ## Sublime Text and XDebug with Drupal VM 19 | 20 | To use XDebug with Sublime Text, change the `php_xdebug_idekey` variable as shown below in `config.yml`, and then run `vagrant provision` to reconfigure the VM: 21 | 22 | ```yaml 23 | php_xdebug_idekey: sublime.xdebug 24 | ``` 25 | 26 | ## NetBeans and XDebug with Drupal VM 27 | 28 | To use XDebug with NetBeans, change the `php_xdebug_idekey` variable as shown below in `config.yml`, and then run `vagrant provision` to reconfigure the VM. 29 | 30 | ```yaml 31 | php_xdebug_idekey: netbeans-xdebug 32 | ``` 33 | -------------------------------------------------------------------------------- /docs/extras/xhprof.md: -------------------------------------------------------------------------------- 1 | As a prerequisite, make sure you have `xhprof` in the `installed_extras` list inside `config.yml` (So the PHP XHProf extension is installed on Drupal VM). 2 | 3 | **Note**: You should disable `xdebug` when enabling/using XHProf, because it is known to have issues running alongside XHProf, and makes test results less reliable and slower than they should be. 4 | 5 | ## XHProf module 6 | 7 | The easiest way to use XHProf to profile your PHP code on a Drupal site is to install the [XHProf](https://www.drupal.org/project/xhprof) module, then in XHProf's configuration (at `/admin/config/development/xhprof`), check the 'Enable profiling of page views and drush requests' checkbox. 8 | 9 | The XHProf module doesn't include built-in support for callgraphs, but there's an issue to [add callgraph support](https://www.drupal.org/node/1470740). 10 | 11 | You can view callgraphs (and a listing of all stored runs) using Drupal VM's own XHProf installation by visiting `http://xhprof.drupalvm.dev/` and clicking on the relevant run, then clicking the "[View Full Callgraph]" link. 12 | 13 | ## Devel module (deprecated) 14 | 15 | The Devel module also *used* to provide XHProf configuration, and setting the options below would allow Devel's XHProf integration to work correctly with Drupal VM's XHProf installation: 16 | 17 | - **xhprof directory**: `/usr/share/php` 18 | - **XHProf URL**: `http://xhprof.drupalvm.dev` (assuming this domain is configured in `apache_vhosts` inside `config.yml`) 19 | -------------------------------------------------------------------------------- /docs/images/drupal-vm-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mark-casias/decoupled-blocks-drupal-vm/7a5587f77eb6c1beacfed834f0ea950465b5b618/docs/images/drupal-vm-logo.png -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | <p align="center"><img src="images/drupal-vm-logo.png" alt="Drupal VM Logo" /></p> 2 | 3 | [Drupal VM](http://www.drupalvm.com/) is A VM for local Drupal development, built with Vagrant + Ansible. 4 | 5 | Welcome to Drupal VM's documentation site! Please read through the [Quick Start Guide](https://github.com/geerlingguy/drupal-vm#quick-start-guide) to get started, and then browse the rest of this project's documentation in the sidebar. 6 | 7 | ## Contributing to Drupal VM 8 | 9 | Please feel free to edit any of the pages in this documentation via the 'Edit on GitHub' link at the top right. If you would like to help improve Drupal VM, feel free to submit new issues or pull requests to the [Drupal VM](https://github.com/geerlingguy/drupal-vm) project on GitHub! 10 | -------------------------------------------------------------------------------- /docs/other/base-os.md: -------------------------------------------------------------------------------- 1 | Drupal VM's configuration is designed to work with RedHat and Debian-compatible operating systems. Therefore, if you switch the `vagrant_box` in `config.yml` to any compatible OS, Drupal VM and all it's configuration should _Just Work™_... but that's not always the case. 2 | 3 | Currently-supported OSes are: 4 | 5 | - Ubuntu 14.04 (default) 6 | - Ubuntu 12.04 7 | - RedHat Enterprise Linux / CentOS 7 8 | - RedHat Enterprise Linux / CentOS 6 9 | 10 | For certain OSes, there are a couple other caveats and tweaks you may need to perform to get things running smoothly—the main features and latest development is only guaranteed to work with the default OS as configured in `example.config.yml`. 11 | 12 | Some other OSes should work, but are not regularly tested with Drupal VM, including Debian 8/Jessie (`debian/jessie64`) and Debian 7/Wheezy (`debian/wheezy64`). 13 | 14 | ## RedHat Enterprise Linux / CentOS 7 15 | 16 | **MySQL/MariaDB**: RHEL/CentOS 7 switched from using MySQL as the default database system to using MariaDB, so to make sure everything is configured properly, you need to add the following to `config.yml` so MariaDB installs correctly: 17 | 18 | ```yaml 19 | mysql_packages: 20 | - mariadb 21 | - mariadb-server 22 | - mariadb-libs 23 | - MySQL-python 24 | - perl-DBD-MySQL 25 | mysql_daemon: mariadb 26 | mysql_socket: /var/lib/mysql/mysql.sock 27 | mysql_log_error: /var/log/mariadb/mariadb.log 28 | mysql_syslog_tag: mariadb 29 | mysql_pid_file: /var/run/mariadb/mariadb.pid 30 | ``` 31 | 32 | ## RedHat Enterprise Linux / CentOS 6 33 | 34 | **Apache without FastCGI**: If you want to use Apache with CentOS 6 on Drupal VM, you will need to modify the syntax of your `apache_vhosts` and remove the `ProxyPassMatch` parameters from each one. Alternatively, you can use Nginx with the default configuration by setting `drupalvm_webserver: nginx` inside `config.yml`. 35 | 36 | **PHP OpCache**: PHP's OpCache (if you're using PHP > 5.5) requires the following setting to be configured in `config.yml` (see upstream bug: [CentOS (6) needs additional php-opcache package](https://github.com/geerlingguy/ansible-role-php/issues/39)): 37 | 38 | ```yaml 39 | php_opcache_enabled_in_ini: false 40 | ``` 41 | -------------------------------------------------------------------------------- /docs/other/bigpipe.md: -------------------------------------------------------------------------------- 1 | [BigPipe](https://www.drupal.org/documentation/modules/big_pipe) is a Drupal module that was added as an 'experimental' module in Drupal 8.1. BigPipe allows PHP responses to be streamed in-progress so authenticated end users can recieve a cached response very quickly, with placeholders for more dynamic (harder to cache) content that are filled in during the same request. 2 | 3 | To do this, BigPipe requires an environment configured to allow the authenticated request response to be streamed from PHP all the way through to the client. All parts of the web stack that intermediate the connection have to have output buffering disabled so the response stream can flow through. 4 | 5 | Drupal VM's default configuration uses Apache with the `mod_proxy_fastcgi` module to connect to PHP-FPM, which isn't the most optimal configuration for BigPipe, and requires gzip compression to be disabled, so you should either switch to Nginx or consider further customizing the Apache configuration. 6 | 7 | Drupal VM's Varnish configuration works with BigPipe out of the box, as it allows the backend response to be streamed whenever BigPipe is enabled (it outputs a `Surrogate-Control: BigPipe/1.0` header to tell Varnish when to stream the response). 8 | 9 | ## PHP configuration 10 | 11 | BigPipe doesn't require any particular modifications to PHP in Drupal VM's default configuration. However, for some scenarios, you might want to disable php's `output_buffering` entirely by setting `php_output_buffering: "Off"` in `config.yml`, or change the `output_buffering` level from it's default of `4096` bytes. 12 | 13 | ## Nginx configuration 14 | 15 | There is no extra configuration required to get BigPipe working with Nginx. 16 | 17 | Nginx is the recommended way to use BigPipe, for the following reasons: 18 | 19 | - It's easier to configure Nginx to handle hundreds (or more) concurrent connections through to PHP-FPM than `mod_php`, and more widely used than the other compatible Apache CGI modules `mod_fcgid` and `mod_fastcgi` 20 | - Nginx intelligently disables output buffering and gzip if the `X-Accel-Buffering: no` header is present (BigPipe sets this header automatically). This means gzip and buffering can be enabled for most requests, and disabled on-the-fly by BigPipe. 21 | 22 | ## Apache configuration 23 | 24 | Apache has three primary means of interacting with PHP applications like Drupal: `mod_php`, `mod_fastcgi`, and `mod_proxy_fcgi`. Drupal VM uses `mod_proxy_fcgi`, which is the most widely used and supported method of using Apache with PHP-FPM for the best scalability and memory management with Apache + PHP. 25 | 26 | For all of these methods, you have to make sure `mod_deflate` gzip compression is disabled; you can do this by adding the following line immediately after the `ProxyPassMatch` line under a host in the `apache_vhosts` list inside `config.yml`: 27 | 28 | SetEnv no-gzip 1 29 | 30 | This will disable the `mod_deflate` module for any requests inside that directory. 31 | 32 | If you want to switch Apache to use `mod_php` instead of proxying requests through PHP-FPM, you can make the following changes in `config.yml`: 33 | 34 | 1. Add `libapache2-mod-php5` to `extra_packages` in `config.yml`. 35 | 2. Delete the `extra_parameters` under any Drupal site in the list of `apache_vhosts` (so there is no `ProxyPassMatch` rule). 36 | 37 | You can also disable PHP-FPM and remove the two `proxy` entries from `apache_mods_enabled` if you don't want to use PHP-FPM with Apache at all, but that's optional; it won't break anything to run Apache with `mod_php` and `mod_proxy_fastcgi` at the same time. 38 | -------------------------------------------------------------------------------- /docs/other/drupal-6.md: -------------------------------------------------------------------------------- 1 | If you'd like to use the included configuration and Drush make file to install a Drupal 6 site using an older version of Drush (< 7.x), you may need to make some changes, namely: 2 | 3 | 1. Drush < 7.x does not support .yml makefiles; if using Drush 5.x or 6.x, you will need to create the make file in the INI-style format. 4 | 2. In your customized `config.yml` file, you will need to use the `default` installation profile instead of `standard` (for the `drupal_install_profile` variable). -------------------------------------------------------------------------------- /docs/other/linux.md: -------------------------------------------------------------------------------- 1 | There are a few caveats when using Drupal VM on Linux, and this page will try to identify the main gotchas or optimization tips for those wishing to use Drupal VM on a Linux host. 2 | 3 | ## Platform-specific Install Instructions 4 | 5 | ### All Linux flavors 6 | 7 | Always make sure your workstation is up to date (e.g. `apt-get update && apt-get upgrade` on Debian-like systems, or `dnf upgrade` or `yum upgrade` on Fedora/RedHat-like systems). There are sometimes bugs in the base OS packages (e.g. [this NFS-related bug](https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1508510)) that can be resolved by a simple upgrade. 8 | 9 | ### Ubuntu 10 | 11 | Ubuntu 15.10 for Desktop (and some other versions) doesn't include NFS support by default, so if you get a message like `It appears your machine doesn't support NFS`, then you should do the following to install NFS server: `sudo apt-get install -y nfs-server`. 12 | 13 | ### Fedora 14 | 15 | Under Fedora, you might encounter a message like the following upon the first time you use VirtualBox or Vagrant: 16 | 17 | ``` 18 | $ vagrant status 19 | VirtualBox is complaining that the kernel module is not loaded. Please 20 | run `VBoxManage --version` or open the VirtualBox GUI to see the error 21 | message which should contain instructions on how to fix this error. 22 | ``` 23 | 24 | In this case, you need to install your system's appropriate kernel module, and you'll also need to install `gcc` and run a specific VirtualBox installation script (or reinstall VirtualBox entirely) so the kernel module is loaded correctly. Do the following: 25 | 26 | 1. `sudo dnf install "kernel-devel-uname-r == $(uname -r)"` 27 | 2. `sudo dnf install gcc` 28 | 3. `sudo /var/lib/vboxdrv.sh setup` 29 | 30 | Periodically, when you upgrade your system's Linux kernel, you might need to run steps 2 and 3 above again, or you can uninstall and reinstall VirtualBox (e.g. `sudo dnf remove VirtualBox && sudo dnf install VirtualBox`). 31 | 32 | ## Synced Folders 33 | 34 | Most issues have to do synced folders. These are the most common ones: 35 | 36 | ### 'Mounting NFS shared folders...' hangs 37 | 38 | There are a few different reasons this particular problem can occur. You may run into the error below during `vagrant up`: 39 | 40 | ``` 41 | The following SSH command responded with a non-zero exit status. 42 | Vagrant assumes that this means the command failed! 43 | 44 | mount -o '' 192.168.88.1:'/Users/myusername/Sites/drupalvm' /var/www/drupalvm 45 | 46 | Stdout from the command: 47 | 48 | 49 | 50 | Stderr from the command: 51 | 52 | stdin: is not a tty 53 | mount.nfs: Connection timed out 54 | ``` 55 | 56 | If you get this message, then it's likely that either NFS isn't running correctly on your host, certain ports are protocols are being blocked by the system firewall, or you need to add additional mount options to your `vagrant_synced_folders` configuration. Try the following fixes: 57 | 58 | 1. On Ubuntu, if you get a message like `It appears your machine doesn't support NFS`, run `sudo apt-get install -y nfs-server`. 59 | 2. Install the `vagrant-vbguest` plugin, which will make sure you are running the latest version of the VirualBox Guest Additions inside the VM (this can solve many different problems!). 60 | 3. Make sure the `vboxnet` interfaces are not being blocked by your system firewall. For Fedora (and many flavors of Linux), check out this guide for more: [Get Vagrant's NFS working under Fedora 20](https://web.archive.org/web/20150706105420/http://blog.bak1an.so/blog/2014/03/23/fedora-vagrant-nfs/). 61 | 4. Add `mount_options: ['vers=3']` to your synced folder definition in config.yml after the other options like `local_path`, `destination`, and `type`. 62 | 63 | After attempting any of the above fixes, run `vagrant reload --provision` to restart the VM and attempt mounting the synced folder again, or `vagrant destroy -f && vagrant up` to rebuild the VM from scratch. 64 | 65 | ## Intel VT-x virtualization support 66 | 67 | On some laptops, Intel VT-x virtualization (which is built into most modern Intel processors) is enabled by default. This allows VirtualBox to run virtual machines efficiently using the CPU itself instead of software CPU emulation. If you get a message like "VT-x is disabled in the bios for both all cpu modes" or something similar, you may need to enter your computer's BIOS or UEFI settings and enable this virtualization support. 68 | -------------------------------------------------------------------------------- /docs/other/local-vagrantfile.md: -------------------------------------------------------------------------------- 1 | Out of the box Drupal VM supports having VirtualBox, Parallels as well as VMware as a provider. Besides these there are multitude of others available (for example `vagrant-aws`, `vagrant-digitalocean`). 2 | 3 | If you want to use an unsupported provider, or otherwise modify the vagrant configuration in a way that is not exposed by Drupal VM, you can create a `Vagrantfile.local` in the root directory of this project. 4 | 5 | The file will be sourced at the end of the `Vagrant.configure` block so you will have access to Vagrant's `config.vm` object as well as the contents of the `config.yml` file within the `vconfig` hash. 6 | 7 | To add a configuration just create a `Vagrantfile.local` in the root like so: 8 | 9 | ```ruby 10 | config.vm.provider :virtualbox do |v| 11 | # Enable GUI mode instead of running a headless machine. 12 | v.gui = true 13 | 14 | # Reduce disk usage of multiple boxes by sharing a master VM. 15 | v.linked_clone = true 16 | 17 | # Cap the host CPU execution at 50% usage. 18 | v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"] 19 | end 20 | ``` 21 | 22 | ## Example: Using the `vagrant-aws` provider 23 | 24 | Add the following variables to your `config.yml`. 25 | 26 | ```yaml 27 | aws_keypair_name: 'keypair' 28 | aws_ami: 'ami-7747d01e' 29 | aws_tags_name: 'Drupal VM' 30 | aws_ssh_username: 'ubuntu' 31 | aws_ssh_private_key: '~/.ssh/aws.pem' 32 | ``` 33 | 34 | Create a `Vagrantfile.local` in the root directory of your project. 35 | 36 | ```ruby 37 | config.vm.provider :aws do |aws, override| 38 | override.nfs.functional = false 39 | 40 | aws.access_key_id = ENV['AWS_ACCESS_KEY_ID'] 41 | aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'] 42 | aws.keypair_name = vconfig['aws_keypair_name'] 43 | aws.tags['Name'] = vconfig['aws_tags_name'] 44 | aws.ami = vconfig['aws_ami'] 45 | 46 | override.ssh.username = vconfig['aws_ssh_username'] 47 | override.ssh.private_key_path = vconfig['aws_ssh_private_key'] 48 | end 49 | ``` 50 | 51 | Add the `AWS_ACCESS_KEY_ID` and the `AWS_SECRET_ACCESS_KEY` environment variables to your shell. 52 | 53 | Then run `vagrant up --provider=aws` to provision the instance. 54 | 55 | _For additional configuring options read the [Vagrant AWS Provider's README](https://github.com/mitchellh/vagrant-aws#readme)_ 56 | -------------------------------------------------------------------------------- /docs/other/management-tools.md: -------------------------------------------------------------------------------- 1 | There are some upstream tools which aid in the creation and management of Drupal VM instances. Some of the more popular tools are listed here. 2 | 3 | If you know of any other tools to help manage Drupal VM, please add them to this page! 4 | 5 | ## Lunchbox 6 | 7 | [Lunchbox](https://github.com/LunchboxDevTools/lunchbox) is a wrapper for the Drupal VM project to manage your Drupal development process. It is a Node.js-based GUI to assist in setting up Drupal VM and creating and managing instances. 8 | 9 | ## Drupal VM Config Generator 10 | 11 | [Drupal VM Config Generator](https://github.com/opdavies/drupal-vm-config-generator) is a Symfony Console application that manages and customises configuration files for Drupal VM projects. 12 | 13 | You can either use the interactive console UI to build configurations, or pass options directly to the `drupalvm-generate` command. 14 | 15 | Examples: 16 | 17 | ``` 18 | drupalvm-generate \ 19 | --hostname=example.com \ 20 | --machine-name=example \ 21 | --ip-address=192.168.88.88 \ 22 | --cpus=1 \ 23 | --memory=512 \ 24 | --webserver=nginx \ 25 | --domain=example.com \ 26 | --path=../site \ 27 | --destination=/var/www/site \ 28 | --docroot=/var/www/site/drupal \ 29 | --drupal-version=8 \ 30 | --build-makefile=no \ 31 | --install-site=true \ 32 | --installed-extras=xdebug,xhprof \ 33 | --force 34 | ``` 35 | 36 | ## Drupal VM Generator 37 | 38 | [generator-drupalvm](https://github.com/kevinquillen/generator-drupalvm) is a Yeoman generator for quickly spawning configured VMs or new projects using Drupal VM. 39 | 40 | Examples: 41 | 42 | ``` 43 | # Generate a new Drupal VM instance in the current directory. 44 | $ yo drupalvm 45 | ``` 46 | 47 | ## Newd 48 | 49 | [`newd`](https://gist.github.com/rgoodie/9966f30b404a4daa59e1) is a bash function that quickly clones the Drupal VM repo wherever you need it, configures important bits, and then kicks off `vagrant up`. 50 | 51 | Examples: 52 | 53 | ``` 54 | # Create a new Drupal VM named 'test-fieldformatter' with Drupal 7. 55 | $ newd 7 test-fieldformatter 56 | 57 | # Create a new Drupal VM named 'drupal8test' with Drupal 8. 58 | $ newd 8 drupal8test 59 | ``` 60 | -------------------------------------------------------------------------------- /docs/other/networking.md: -------------------------------------------------------------------------------- 1 | Since Vagrant manages internal network connections for Drupal VM, and since every person's network setup is unique, there are sometimes networking issues that require some adjustments to your Drupal VM configuration or a computer reboot. 2 | 3 | ## Network Route Collision 4 | 5 | Drupal VM comes configured with the default IP address `192.168.88.88`. If you're connected to a LAN with the same private IP address range (e.g. `192.168.x.x`), then VirtualBox or VMware will not be able to set up the VM with the default IP address, because that would conflict with the `192.168.x.x` network your computer is using. 6 | 7 | In this case, you have two options: 8 | 9 | 1. Switch the `vagrant_ip` in `config.yml` to a different private IP address, e.g. `172.16.0.88` or `10.0.1.88`. 10 | 2. Install the `vagrant-auto_network` plugin (`vagrant plugin install vagrant-auto_network`), and set the `vagrant_ip` to `0.0.0.0`. 11 | 12 | Another cause of route collisions is the use of multiple VM providers on your computer. If you have both VirtualBox and VMware Fusion, and you have VMs running in both, and you attempt to use the same IP range in both providers, you'll hit a networking conflict. In this case, the only easy way to restore connectivity is to restart your host machine. 13 | -------------------------------------------------------------------------------- /docs/other/php-7.md: -------------------------------------------------------------------------------- 1 | Drupal VM fully supports PHP 7, but currently defaults to 5.6 in order to maximize compatibility with older Drupal 6 and 7 sites. Soon, Drupal VM will change its defaults to install PHP 7.x instead of 5.x, but until then, follow the instructions below to use PHP 7. 2 | 3 | _Note: If you have Ansible installed on your host machine, make sure you're running the latest version of all Ansible role dependencies by running `ansible-galaxy install -r provisioning/requirements.yml --force` inside the root Drupal VM project folder._ 4 | 5 | ## Ubuntu 14.04 6 | 7 | Ondřej Surý's PPA for PHP 7.0 is included with Drupal VM, and you can make the following changes/additions to `config.yml` to use it: 8 | 9 | ```yaml 10 | php_version: "7.0" 11 | php_packages: 12 | - php7.0-common 13 | - php7.0-cli 14 | - php7.0-dev 15 | - php7.0-fpm 16 | - libpcre3-dev 17 | - php7.0-gd 18 | - php7.0-curl 19 | - php7.0-imap 20 | - php7.0-json 21 | - php7.0-opcache 22 | - php7.0-xml 23 | - php7.0-mbstring 24 | php_mysql_package: php7.0-mysql 25 | php_fpm_daemon: php7.0-fpm 26 | php_fpm_pool_conf_path: "/etc/php/7.0/fpm/pool.d/www.conf" 27 | ``` 28 | 29 | Also, comment out `xhprof`, `xdebug`, `redis` and `memcached` from the `installed_extras` list, as these extensions are not yet supported for PHP 7 (as of late 2015). 30 | 31 | You can also build from source using the same/included `geerlingguy.php` Ansible role, but that process is a bit more involved and for power users comfortable with the process. 32 | 33 | ## RedHat/CentOS 7 34 | 35 | Remi's RPM repository is included with Drupal VM, and you can make the following changes to use it to install PHP 7: 36 | 37 | 1. Make sure you've followed the directions for switching to CentOS 7 in the [use a different base OS](base-os.md) guide. 38 | 2. Change `php_version` inside `config.yml` to `"7.0"`. 39 | 3. Comment out `xhprof`, `xdebug`, `redis` and `memcached` from the `installed_extras` list, as these extensions are not yet supported for PHP 7 (as of early 2016). 40 | -------------------------------------------------------------------------------- /docs/other/vagrant-virtualbox.md: -------------------------------------------------------------------------------- 1 | From time to time, users have reported particular issues with Vagrant or VirtualBox in certain environments, and this page shows some common issues and possible fixes/solutions. 2 | 3 | ## Guest additions fail to be detected 4 | 5 | From time to time, if you `vagrant halt`, then `vagrant up` again, you might get a message like `No guest additions were detected on the base box for this VM!`, as well as messages about shared folders not working correctly. 6 | 7 | There are two ways you can fix this problem: 8 | 9 | 1. Make sure you're running the latest box version for Drupal VM. Update by running `vagrant box update`. 10 | 2. Install the `vagrant vbguest` plugin: `vagrant plugin install vagrant-vbguest`. 11 | -------------------------------------------------------------------------------- /docs/other/webservers.md: -------------------------------------------------------------------------------- 1 | Drupal VM's configuration works with multiple operating systems _and_ with multiple webservers. You can switch between Apache and Nginx (depending on which server you prefer) with ease. 2 | 3 | All you need to do is change the `drupalvm_webserver` variable inside your customized `config.yml`, choosing either `apache` or `nginx`. 4 | 5 | Because the webservers are configured somewhat differently, there are a few things you should configure depending on which webserver you use. 6 | 7 | ## Using Apache 8 | 9 | You have complete control over all aspects of Apache VirtualHosts using the `apache_vhosts` configuration. A few simple examples are shown in `example.config.yml`, but this configuration can be much more complex. 10 | 11 | See the examples included in the [`geerlingguy.apache` Ansible role's README](https://github.com/geerlingguy/ansible-role-apache#readme) for more info, as well as many other variables you can override to configure Apache exactly how you like it. 12 | 13 | ## Using Nginx 14 | 15 | Because Nginx server directives behave a little differently than Apache's VirtualHosts, Drupal VM includes a custom Drupal-optimized Nginx server block configuration, and you can control all the servers ('virtual hosts') Nginx will run using the `nginx_hosts` configuration. A few simple examples are shown in `example.config.yml`, but you have some extra flexibility if you need it. See the `nginx-vhost.conf.j2` template for more information. 16 | 17 | Also, see the examples included in the [`geerlingguy.nginx` Ansible role's README](https://github.com/geerlingguy/ansible-role-nginx#readme) for more info, as well as many other variables you can override to configure Nginx exactly how you like it. 18 | -------------------------------------------------------------------------------- /docs/other/windows.md: -------------------------------------------------------------------------------- 1 | There are a few caveats when using Drupal VM on Windows, and this page will try to identify the main gotchas or optimization tips for those wishing to use Drupal VM on a Windows host. 2 | 3 | ## Command line environment 4 | 5 | You can use PowerShell, Git Bash, Git Shell, or other PowerShell-based environments with Drupal VM and Vagrant; however you might want to consider using a more POSIX-like environment so you can more easily work with Drupal VM: 6 | 7 | - [Cmder](http://cmder.net/) includes built-in git and SSH support, so you can do most things that you need without any additional plugins. 8 | - [Cygwin](https://www.cygwin.com/) allows you to install a large variety of linux packages inside its bash environment, though it can be a little more tricky to manage and is less integrated into the Windows environment. 9 | 10 | ## Synced Folders 11 | 12 | Most issues have to do synced folders. These are the most common ones: 13 | 14 | ### Performance 15 | 16 | By default, if you use the 'NFS' synced folder type, Vagrant will ignore this directive and use the native (usually slow) VirtualBox shared folder system instead. You can get higher performance by doing one of the following (all of these steps require a full VM reload (`vagrant reload`) to take effect): 17 | 18 | 1. **Install the `vagrant-winnfsd` plugin**. See the 'NFS' section later for more details and caveats. 19 | 2. **Use `smb` for the synced folder's type.** 20 | 2. **Use `rsync` for the synced folder's type.** This requires that you have `rsync` available on your Windows workstation, which you can get if you install a substitute CLI like [Cygwin](https://www.cygwin.com/) or [Cmder](http://cmder.net/). 21 | 22 | ### Symbolic Links 23 | 24 | Creating symbolic links in a shared folder will fail with a permission or protocol error. 25 | 26 | There are two parts to this: 27 | 28 | 1. VirtualBox does not allow gets VMs to create symlinks in synced folders by default. 29 | 2. Windows does not allow the creation of symlinks unless your local policy allows it; see [TechNet article](https://technet.microsoft.com/en-us/library/dn221947%28v=ws.10%29.aspx). Even if local policy allows it, many users experience problems in the creation of symlinks. 30 | 31 | ### Git and File permissions 32 | 33 | If you're using a synced folder for your project, you should choose to either work _only_ inside the VM, or _only_ on the host machine. Don't commit changes both inside the VM and on the host unless you know what you're doing and have Git configured properly for Unix vs. Windows line endings. File permissions and line endings can be changed in ways that can break your project if you're not careful! 34 | 35 | You should probably disable Git's `fileMode` option inside the VM and on your host machine if you're running Windows and making changes to a Git repository: 36 | 37 | git config core.fileMode false 38 | 39 | ### NFS 40 | 41 | You can use the [vagrant-winnfsd](https://github.com/GM-Alex/vagrant-winnfsd) plugin to get NFS support on windows. Be aware that there are multiple issues logged against both the plugin and the winnfsd project, so no guarantees. 42 | 43 | #### Using WinNFSD without `vagrant-winnfsd` 44 | 45 | Another option for the more adventurous is to manually install and configure WinNFSD, and manually mount the shares within your VM. This requires a bit more work, but could be more stable on Windows; see this blog post for more details: [Windows + Vagrant + WinNFSD without file update problems](https://hollyit.net/blog/windowsvagrantwinnfsd-without-file-update-problems). 46 | 47 | ### "Authentication failure" on vagrant up 48 | 49 | Some Windows users have reported running into an issue where an authentication failure is reported once the VM is booted (e.g. `drupalvm: Warning: Authentication failure. Retrying...` — see [#170](https://github.com/geerlingguy/drupal-vm/issues/170)). To fix this, do the following: 50 | 51 | 1. Delete `~/.vagrant.d/insecure_private_key` 52 | 2. Run `vagrant ssh-config` 53 | 3. Restart the VM with `vagrant reload` 54 | 55 | ### Windows 7 requires PowerShell upgrade 56 | 57 | If you are running Windows 7 and `vagrant up` hangs, you may need to upgrade PowerShell. Windows 7 ships with PowerShell 2.0, but PowerShell 3.0 or higher is required. For Windows 7, you can upgrade to PowerShell 4.0 which is part of the [Windows Management Framework](http://www.microsoft.com/en-us/download/details.aspx?id=40855). 58 | 59 | ## Hosts file updates 60 | 61 | If you install either the `vagrant-hostsupdater` or `vagrant-hostmanager` plugin, you might get a permissions error when Vagrant tries changing the hosts file. On a Mac or Linux workstation, you're prompted for a sudo password so the change can be made, but on Windows, you have to do one of the following to make sure hostsupdater works correctly: 62 | 63 | 1. Run PowerShell or whatever CLI you use with Vagrant as an administrator. Right click on the application and select 'Run as administrator', then proceed with `vagrant` commands as normal. 64 | 2. Change the permissions on the hosts file so your account has permission to edit the file (this has security implications, so it's best to use option 1 unless you know what you're doing). To do this, open `%SystemRoot%\system32\drivers\etc` in Windows Explorer, right-click the `hosts` file, and under Security, add your account and give yourself full access to the file. 65 | 66 | ## Intel VT-x virtualization support 67 | 68 | On some laptops, Intel VT-x virtualization (which is built into most modern Intel processors) is enabled by default. This allows VirtualBox to run virtual machines efficiently using the CPU itself instead of software CPU emulation. If you get a message like "VT-x is disabled in the bios for both all cpu modes" or something similar, you may need to enter your computer's BIOS settings and enable this virtualization support. 69 | -------------------------------------------------------------------------------- /example.config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # `vagrant_box` can also be set to geerlingguy/centos6, geerlingguy/centos7, 3 | # geerlingguy/ubuntu1204, parallels/ubuntu-14.04, etc. 4 | vagrant_box: geerlingguy/ubuntu1404 5 | vagrant_user: vagrant 6 | vagrant_synced_folder_default_type: nfs 7 | 8 | # If you need to run multiple instances of Drupal VM, set a unique hostname, 9 | # machine name, and IP address for each instance. 10 | vagrant_hostname: decoupled.dev 11 | vagrant_machine_name: decoupled 12 | vagrant_ip: 192.168.88.94 13 | 14 | # Allow Drupal VM to be accessed via a public network interface on your host. 15 | # Vagrant boxes are insecure by default, so be careful. You've been warned! 16 | # See: https://docs.vagrantup.com/v2/networking/public_network.html 17 | vagrant_public_ip: "" 18 | 19 | # A list of synced folders, with the keys 'local_path', 'destination', and 20 | # a 'type' of [nfs|rsync|smb] (leave empty for slow native shares). See 21 | # http://docs.drupalvm.com/en/latest/extras/syncing-folders/ for more info. 22 | vagrant_synced_folders: 23 | # The first synced folder will be used for the default Drupal installation, if 24 | # build_makefile: is 'true'. 25 | - local_path: ~/Sites/decoupled.dev 26 | destination: /var/www/decoupled.dev 27 | type: nfs 28 | create: true 29 | 30 | # Memory and CPU to use for this VM. 31 | vagrant_memory: 1024 32 | vagrant_cpus: 2 33 | 34 | # The web server software to use. Can be either 'apache' or 'nginx'. 35 | drupalvm_webserver: apache 36 | 37 | # Set this to false if you are using a different site deployment strategy and 38 | # would like to configure 'vagrant_synced_folders' and 'apache_vhosts' manually. 39 | build_makefile: true 40 | drush_makefile_path: ../../drupal.make.yml 41 | 42 | # Set this to false if you don't need to install drupal (using the drupal_* 43 | # settings below), but instead copy down a database (e.g. using drush sql-sync). 44 | install_site: true 45 | 46 | # Settings for building a Drupal site from a makefile (if 'build_makefile:' 47 | # is 'true'). 48 | drupal_major_version: 8 49 | drupal_core_path: "/var/www/decoupled.dev/drupal" 50 | drupal_domain: "{{ vagrant_hostname }}" 51 | drupal_site_name: "Decoupled Blocks" 52 | drupal_install_profile: standard 53 | drupal_enable_modules: [ 'devel' ] 54 | drupal_account_name: admin 55 | drupal_account_pass: admin 56 | drupal_mysql_user: drupal 57 | drupal_mysql_password: drupal 58 | drupal_mysql_database: drupal 59 | 60 | # Additional arguments or options to pass to `drush site-install`. 61 | drupal_site_install_extra_args: [] 62 | 63 | # Cron jobs are added to the root user's crontab. Keys include name (required), 64 | # minute, hour, day, weekday, month, job (required), and state. 65 | drupalvm_cron_jobs: [] 66 | # - { 67 | # name: "Drupal Cron", 68 | # minute: "*/30", 69 | # job: "drush -r {{ drupal_core_path }} core-cron" 70 | # } 71 | 72 | # Drupal VM automatically creates a drush alias file in your ~/.drush folder if 73 | # this variable is 'true'. 74 | configure_local_drush_aliases: true 75 | 76 | # Apache VirtualHosts. Add one for each site you are running inside the VM. For 77 | # multisite deployments, you can point multiple servernames at one documentroot. 78 | # View the geerlingguy.apache Ansible Role README for more options. 79 | apache_vhosts: 80 | - servername: "{{ drupal_domain }}" 81 | documentroot: "{{ drupal_core_path }}" 82 | extra_parameters: | 83 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}" 84 | 85 | - servername: "adminer.{{ vagrant_hostname }}" 86 | documentroot: "{{ adminer_install_dir }}" 87 | extra_parameters: | 88 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ adminer_install_dir }}" 89 | 90 | - servername: "xhprof.{{ vagrant_hostname }}" 91 | documentroot: "{{ php_xhprof_html_dir }}" 92 | extra_parameters: | 93 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ php_xhprof_html_dir }}" 94 | 95 | - servername: "pimpmylog.{{ vagrant_hostname }}" 96 | documentroot: "{{ pimpmylog_install_dir }}" 97 | extra_parameters: | 98 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ pimpmylog_install_dir }}" 99 | 100 | - servername: "{{ vagrant_ip }}" 101 | serveralias: "dashboard.{{ vagrant_hostname }}" 102 | documentroot: "{{ dashboard_install_dir }}" 103 | 104 | apache_remove_default_vhost: true 105 | apache_mods_enabled: 106 | - expires.load 107 | - ssl.load 108 | - rewrite.load 109 | - proxy.load 110 | - proxy_fcgi.load 111 | 112 | # Nginx hosts. Each site will get a server entry using the configuration defined 113 | # here. Set the 'is_php' property for document roots that contain PHP apps like 114 | # Drupal. 115 | nginx_hosts: 116 | - server_name: "{{ drupal_domain }}" 117 | root: "{{ drupal_core_path }}" 118 | is_php: true 119 | 120 | - server_name: "adminer.{{ vagrant_hostname }}" 121 | root: "{{ adminer_install_dir }}" 122 | is_php: true 123 | 124 | - server_name: "xhprof.{{ vagrant_hostname }}" 125 | root: "{{ php_xhprof_html_dir }}" 126 | is_php: true 127 | 128 | - server_name: "pimpmylog.{{ vagrant_hostname }}" 129 | root: "{{ pimpmylog_install_dir }}" 130 | is_php: true 131 | 132 | - server_name: "{{ vagrant_ip }} dashboard.{{ vagrant_hostname }}" 133 | root: "{{ dashboard_install_dir }}" 134 | 135 | nginx_remove_default_vhost: true 136 | nginx_ppa_use: true 137 | 138 | # MySQL Databases and users. If build_makefile: is true, first database will 139 | # be used for the makefile-built site. 140 | mysql_databases: 141 | - name: "{{ drupal_mysql_database }}" 142 | encoding: utf8 143 | collation: utf8_general_ci 144 | 145 | mysql_users: 146 | - name: "{{ drupal_mysql_user }}" 147 | host: "%" 148 | password: "{{ drupal_mysql_password }}" 149 | priv: "{{ drupal_mysql_database }}.*:ALL" 150 | 151 | # Comment out any extra utilities you don't want to install. If you don't want 152 | # to install *any* extras, make set this value to an empty set, e.g. `[]`. 153 | installed_extras: 154 | - adminer 155 | - drupalconsole 156 | - mailhog 157 | - memcached 158 | # - nodejs 159 | - pimpmylog 160 | # - redis 161 | # - ruby 162 | # - selenium 163 | # - solr 164 | - varnish 165 | - xdebug 166 | - xhprof 167 | 168 | # Add any extra apt or yum packages you would like installed. 169 | extra_packages: [] 170 | 171 | # `nodejs` must be in installed_extras for this to work. Valid examples: "0.10", 172 | # "0.12", "4.x", "5.x". 173 | nodejs_version: "0.12" 174 | nodejs_npm_global_packages: [] 175 | 176 | # `ruby` must be in installed_extras for this to work. 177 | ruby_install_gems_user: "{{ drupalvm_user }}" 178 | ruby_install_gems: [] 179 | 180 | # You can configure almost anything else on the server in the rest of this file. 181 | extra_security_enabled: false 182 | 183 | drush_version: "master" 184 | drush_keep_updated: true 185 | drush_composer_cli_options: "--prefer-dist --no-interaction" 186 | 187 | firewall_allowed_tcp_ports: 188 | - "22" 189 | - "25" 190 | - "80" 191 | - "81" 192 | - "443" 193 | - "4444" 194 | - "8025" 195 | - "8080" 196 | - "8443" 197 | - "8983" 198 | firewall_log_dropped_packets: false 199 | 200 | # PHP Configuration. Currently-supported versions: 5.5, 5.6, 7.0. 201 | # PHP 7.0 requires a few additional changes. See the documentation at 202 | # http://docs.drupalvm.com/en/latest/other/php-7/ 203 | php_version: "5.6" 204 | php_memory_limit: "192M" 205 | php_display_errors: "On" 206 | php_display_startup_errors: "On" 207 | php_realpath_cache_size: "1024K" 208 | php_sendmail_path: "/usr/sbin/ssmtp -t" 209 | php_opcache_enabled_in_ini: true 210 | php_opcache_memory_consumption: "192" 211 | php_opcache_max_accelerated_files: 4096 212 | php_max_input_vars: "4000" 213 | 214 | # Drupal VM defaults to using PHP-FPM with either Apache or Nginx. If you wish 215 | # to instead use Apache + mod_php with an Ubuntu base box, make sure you add 216 | # libapache2-mod-php5 to `extra_packages` elsewhere in this config file. 217 | php_enable_php_fpm: true 218 | php_fpm_listen: "127.0.0.1:9000" 219 | 220 | composer_path: /usr/bin/composer 221 | composer_home_path: "/home/{{ drupalvm_user }}/.composer" 222 | composer_home_owner: "{{ drupalvm_user }}" 223 | composer_home_group: "{{ drupalvm_user }}" 224 | # composer_global_packages: 225 | # - { name: phpunit/phpunit, release: '@stable' } 226 | 227 | # Run specified scripts after VM is provisioned. Path is relative to the 228 | # `provisioning/playbook.yml` file. 229 | post_provision_scripts: [] 230 | # - "../examples/scripts/configure-solr.sh" 231 | 232 | # MySQL Configuration. 233 | mysql_root_password: root 234 | mysql_slow_query_log_enabled: true 235 | mysql_slow_query_time: 2 236 | mysql_wait_timeout: 300 237 | adminer_install_filename: index.php 238 | 239 | # Varnish Configuration. 240 | varnish_listen_port: "81" 241 | varnish_default_vcl_template_path: templates/drupalvm.vcl.j2 242 | varnish_default_backend_host: "127.0.0.1" 243 | varnish_default_backend_port: "80" 244 | 245 | # Pimp my Log settings. 246 | pimpmylog_install_dir: /usr/share/php/pimpmylog 247 | pimpmylog_grant_all_privs: true 248 | 249 | # XDebug configuration. XDebug is disabled by default for better performance. 250 | php_xdebug_default_enable: 0 251 | php_xdebug_coverage_enable: 0 252 | php_xdebug_cli_enable: 1 253 | php_xdebug_remote_enable: 1 254 | php_xdebug_remote_connect_back: 1 255 | # Use PHPSTORM for PHPStorm, sublime.xdebug for Sublime Text. 256 | php_xdebug_idekey: PHPSTORM 257 | php_xdebug_max_nesting_level: 256 258 | 259 | # Solr Configuration (if enabled above). 260 | solr_version: "4.10.4" 261 | solr_xms: "64M" 262 | solr_xmx: "128M" 263 | 264 | # Selenium configuration. 265 | selenium_version: 2.46.0 266 | 267 | # Other configuration. 268 | dashboard_install_dir: /var/www/dashboard 269 | known_hosts_path: ~/.ssh/known_hosts 270 | -------------------------------------------------------------------------------- /example.drupal.make.yml: -------------------------------------------------------------------------------- 1 | --- 2 | api: 2 3 | 4 | # Basic Drush Make file for Drupal. Be sure to update the drupal_major_version 5 | # variable inside config.yml if you change the major version in this file. 6 | 7 | # Drupal core (major version, e.g. 6.x, 7.x, 8.x). 8 | core: "8.x" 9 | 10 | projects: 11 | 12 | # Core. 13 | drupal: 14 | type: "core" 15 | download: 16 | # Drupal core branch (e.g. "6.x", "7.x", "8.0.x"). 17 | branch: "8.1.x" 18 | working-copy: false 19 | 20 | # Other modules. 21 | devel: "1.x-dev" 22 | admin_toolbar: "1.14" 23 | pdb: 24 | download: 25 | type: "git" 26 | url: "git://github.com/mrjmd/decoupled_blocks.git" 27 | branch: "8.x-1.x" 28 | working-copy: true 29 | -------------------------------------------------------------------------------- /examples/acquia/README.md: -------------------------------------------------------------------------------- 1 | # Acquia Cloud Drupal VM Configuration Example 2 | 3 | This directory contains example configuration changes for the default Drupal VM `example.config.yml` file which emulate the default Acquia Cloud environment with Drupal VM: 4 | 5 | - Ubuntu 12.04.5 LTS 6 | - Apache 2.2.22 7 | - PHP 5.5.23 8 | - MySQL/Percona 5.5.24 9 | - Apache Solr 4.5.1 10 | 11 | To use these overrides, copy `example.config.yml` to `config.yml` as you would normally, but make sure the variables defined in `acquia.overrides.yml` are defined with the same values in your `config.yml` file. 12 | -------------------------------------------------------------------------------- /examples/acquia/acquia.overrides.yml: -------------------------------------------------------------------------------- 1 | --- 2 | vagrant_box: geerlingguy/ubuntu1204 3 | php_version: "5.6" 4 | solr_version: "4.5.1" 5 | -------------------------------------------------------------------------------- /examples/prod/README.md: -------------------------------------------------------------------------------- 1 | # Drupal VM Production Configuration Example 2 | 3 | > **Important**: This feature is currently in 'experimental' status, and the security of your servers is _your_ responsibility. 4 | 5 | This directory contains an example production configuration for Drupal VM which can be used to deploy Drupal VM to a production environment on a cloud provider like DigitalOcean, Linode, or AWS. 6 | 7 | This README file contains instructions for how you can use this configuration file to build a Drupal environment with Drupal VM on DigitalOcean. 8 | 9 | ## Create a DigitalOcean Droplet 10 | 11 | If you don't already have a DigitalOcean account, create one (you can use geerlingguy's [affiliate link](https://www.digitalocean.com/?refcode=b9c57af84643) to sign up, otherwise, visit the normal [DigitalOcean Sign Up form](https://cloud.digitalocean.com/registrations/new). 12 | 13 | Make sure you have an SSH key you can use to connect to your DigitalOcean droplets, and if you don't already have one set up, or if you need to add your existing key to your account, follow the instructions in this guide: [How to use SSH keys with DigitalOcean Droplets](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets). 14 | 15 | Once you are logged into DigitalOcean and have added your SSH key, click the 'Create Droplet' button on your Droplets page. For the Droplet, choose the following options: 16 | 17 | - **Image**: Choose `Ubuntu 14.04.x x64` 18 | - **Size**: 1 GB / 1 CPU (currently $10/month; you can choose a higher plan if needed) 19 | - **Region**: Choose whatever region is geographically nearest to you and your site visitors 20 | - **Settings**: (Nothing here affects how Drupal VM works, choose what you'd like) 21 | - **Add SSH Keys**: Select the SSH key you added to your account earlier. 22 | - **Hostname**: Choose a hostname for your site (e.g. `example.drupalvm.com`) 23 | 24 | Click 'Create Droplet', and wait a minute or so while the Droplet is booted. Once it's booted, make sure you can log into it from your local computer: 25 | 26 | ssh root@[droplet-hostname-or-ip] 27 | 28 | (Make sure you replace `[droplet-hostname-or-ip]`) with the hostname or IP address of your Droplet!) 29 | 30 | If you get a warning like "the authenticity of the host can't be established", answer yes to the prompt and hit enter. You should now be logged into the Droplet. Log back out by typing `exit` at the prompt and hitting return. 31 | 32 | Your DigitalOcean Droplet is booted and ready to have Drupal VM installed on it. 33 | 34 | ## Customize `config.yml` and `inventory` for production 35 | 36 | Just like you would with the normal `example.config.yml`, you need to copy the file to `config.yml`, then go through `prod.overrides.yml` (in this directory), and make sure to update your `config.yml`, making sure all the variables are set to match `prod.overrides.yml`. 37 | 38 | The changes outlined in `prod.overrides.yml` disable development-environment tools (like Pimp My Log and Adminer) and add extra security hardening configuration (via the `extra_security_enabled` variable). 39 | 40 | The only other thing you need to do is copy the inventory file `example.inventory` to `inventory` (so it is located at `prod/inventory`). By default, it reads: 41 | 42 | [drupalvm] 43 | 1.2.3.4 ansible_ssh_user=my_admin_username 44 | 45 | Change the host `1.2.3.4` to either the IP address or the hostname of your DigitalOcean Droplet. Remember that if you would like to use a hostname, you need to make sure the hostname actually resolves to your Droplet's IP address, either in your domain's public DNS configuration, or via your local hosts file. 46 | 47 | ## Initialize the server with an administrative account 48 | 49 | > Note: This guide assumes you have Ansible [installed](http://docs.ansible.com/ansible/intro_installation.html) on your host machine. 50 | 51 | The first step in setting up Drupal VM on the cloud server is to initialize the server with an administrative account (which is separate from the `root` user account for better security). 52 | 53 | Inside the `examples/prod/bootstrap` folder, copy the `example.vars.yml` file to `vars.yml` and update the variables in that file for your own administrative account (make sure especially to update the `admin_password` value!). 54 | 55 | Then, run the following command within Drupal VM's root directory (the folder containing the `Vagrantfile`): 56 | 57 | ansible-playbook -i examples/prod/inventory examples/prod/bootstrap/init.yml -e "ansible_ssh_user=root" 58 | 59 | Once the initialization is complete, you can test your new admin login with `ssh my_admin_username@droplet-hostname-or-ip`. You should be logged in via your existing SSH key. Log back out with `exit`. 60 | 61 | ## Provision Drupal VM on the Droplet 62 | 63 | Run the following command within Drupal VM's root directory (the folder containing the `Vagrantfile`): 64 | 65 | ansible-playbook -i examples/prod/inventory provisioning/playbook.yml --sudo --ask-sudo-pass 66 | 67 | Ansible will prompt you for your admin account's `sudo` password (the same as the password you encrypted and saved as `admin_password`). Enter it and press return. 68 | 69 | After a few minutes, your Drupal-VM-in-the-cloud Droplet should be fully configured to match your local development environment! You can visit your Droplet and access the fresh Drupal site just like you would locally (e.g. `http://example.drupalvm.com/`). 70 | 71 | ## Known issues 72 | 73 | - You may need to manually create the `drupal_core_path` directory on the server at this time; it's not always created automatically due to permissions errors. 74 | - The `files` folder that is generated during the initial Drupal installation is set to be owned by the admin account; to make it work (and to allow Drupal to generate stylesheets and files correctly), you have to manually log into the server and run the following two commands after provisioning is complete: 75 | 76 | ``` 77 | $ sudo chown -R www-data /var/www/drupalvm/drupal/sites/default/files 78 | $ sudo chmod -R 0700 /var/www/drupalvm/drupal/sites/default/files 79 | ``` 80 | 81 | - You can't synchronize folders between your host machine and DigitalOcean (at least not in any sane way); so you'll need to either have Drupal VM install a site from a given Drush make file or composer.json, or deploy your site yourself. 82 | - The way you build a production Drupal VM instance (vs. a local instance) is a little bit of a kludge. Follow https://github.com/geerlingguy/drupal-vm/issues/455 to track progress on a more streamlined process. 83 | - Drupal VM doesn't include any kind of backup system. You should use one if you have any kind of important data on your server! 84 | 85 | ## Go Further 86 | 87 | You can use Ubuntu 12.04, Ubuntu 14.04, CentOS 6 or CentOS 7 when you build the DigitalOcean Droplet. Just like with Drupal VM running locally, you can customize almost every aspect of the server! 88 | 89 | You may want to customize your configuration even further, to make sure Drupal VM is tuned for your specific Drupal site's needs, or you may want to change things and make the server configuration more flexible, etc. For all that, the book [Ansible for DevOps](http://ansiblefordevops.com/) will give you a great introduction to using Ansible to make Drupal VM and the included Ansible configuration do exactly what you need! 90 | -------------------------------------------------------------------------------- /examples/prod/bootstrap/example.vars.yml: -------------------------------------------------------------------------------- 1 | --- 2 | admin_user: my_admin_username 3 | 4 | # On RHEL/CentOS, 'wheel'; on Debian/Ubuntu, 'root'. 5 | admin_group: root 6 | 7 | # IMPORTANT: Configure your own password for the admin user account. To generate 8 | # a password hash, use either of the following commands: 9 | # - `openssl passwd -1 [password]` 10 | # - `mkpasswd --method=SHA-512`. 11 | admin_password: $1$HgT69GsW$qZ8FUJHafZZWD76KXgAZO/ 12 | 13 | # Configuration for copying local public SSH key to admin's authorized_keys. 14 | admin_copy_ssh_pubkey: true 15 | admin_pubkey: ~/.ssh/id_rsa.pub 16 | -------------------------------------------------------------------------------- /examples/prod/bootstrap/init.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: drupalvm 3 | 4 | vars_files: 5 | - vars.yml 6 | 7 | tasks: 8 | - name: Create admin user account. 9 | user: 10 | name: "{{ admin_user }}" 11 | createhome: yes 12 | home: "/home/{{ admin_user }}" 13 | generate_ssh_key: yes 14 | ssh_key_comment: "ansible-{{ inventory_hostname }}" 15 | password: "{{ admin_password }}" 16 | groups: "{{ admin_group }}" 17 | shell: /bin/bash 18 | 19 | - name: Add local SSH public key to admin account authorized_keys. 20 | authorized_key: 21 | user: "{{ admin_user }}" 22 | key: "{{ lookup('file', '{{ admin_pubkey }}') }}" 23 | manage_dir: yes 24 | 25 | - name: Disable requiretty. 26 | lineinfile: 27 | dest: /etc/sudoers 28 | regexp: '^Defaults.+requiretty' 29 | line: 'Defaults !requiretty' 30 | state: present 31 | -------------------------------------------------------------------------------- /examples/prod/example.inventory: -------------------------------------------------------------------------------- 1 | [drupalvm] 2 | 1.2.3.4 ansible_ssh_user=my_admin_username 3 | -------------------------------------------------------------------------------- /examples/prod/prod.overrides.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Normally, this would be set to the hostname of your DigitalOcean Droplet. 3 | drupal_domain: "drupalvm.dev" 4 | 5 | # Delete all the `apache_vhosts` or `nginx_hosts` you don't need. If only 6 | # installing a single Drupal site, the variable should look like this (Apache): 7 | apache_vhosts: 8 | - servername: "{{ drupal_domain }}" 9 | documentroot: "{{ drupal_core_path }}" 10 | extra_parameters: | 11 | ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000{{ drupal_core_path }}" 12 | 13 | # Since this will be a publicly-accessible instance of Drupal VM, make sure you 14 | # configure secure passwords, especially for Drupal and MySQL! 15 | drupal_account_pass: admin 16 | drupal_mysql_password: drupal 17 | mysql_root_password: root 18 | 19 | # Only install extras that you will need/use on your site, and don't install 20 | # development-related software on production environments! 21 | installed_extras: 22 | # - memcached 23 | # - redis 24 | # - solr 25 | - varnish 26 | 27 | # Disable the dashboard page. Also remove any unneeded virtualhosts. 28 | dashboard_install_dir: '' 29 | 30 | # Enable a more hardened security configuration. 31 | extra_security_enabled: true 32 | 33 | # Restrict the firewall to only ports that are required for external services. 34 | firewall_allowed_tcp_ports: 35 | - "22" 36 | - "80" 37 | - "443" 38 | firewall_log_dropped_packets: true 39 | 40 | # Set Apache to listen on port 81 (internal only), and Varnish on 80. 41 | apache_listen_port: "81" 42 | varnish_listen_port: "80" 43 | varnish_default_backend_port: "81" 44 | -------------------------------------------------------------------------------- /examples/scripts/README.md: -------------------------------------------------------------------------------- 1 | # Example Scripts for Drupal VM 2 | 3 | ## Post-Provision Scripts 4 | 5 | Drupal VM allows you to run extra shell scripts at the end of the provisioning process, in case you need to do extra custom setup, configure your environment, or install extra software outside the purview of Drupal VM. 6 | 7 | To use an extra script, configure the path to the script (relative to `provisioning/playbook.yml`) in `config.yml`: 8 | 9 | ```yaml 10 | post_provision_scripts: 11 | - "../examples/post-provision.sh" 12 | ``` 13 | 14 | The above example results in the example `post-provision.sh` script running after the main Drupal VM setup is complete. Note that this script would run _every_ time you provision the environment (e.g. once when you run `vagrant up`, then again every time you run `vagrant provision` again). 15 | 16 | You can define as many scripts as you would like, and any arguments after the path will be passed to the shell script itself (e.g. `"../examples/post-provision.sh --option"`). 17 | 18 | Generally, you should place your post-provision scripts inside a `scripts` directory in the root of your Drupal VM project directory; this directory is gitignored, so you can continue to update Drupal VM without accidentally overwriting your scripts. 19 | -------------------------------------------------------------------------------- /examples/scripts/configure-solr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Example shell script to run post-provisioning. 4 | # 5 | # This script configures the default Apache Solr search core to use one of the 6 | # Drupal Solr module's configurations. This shell script presumes you have 7 | # `solr` in the `installed_extras`, and is currently set up for the D7 versions 8 | # of Apache Solr Search or Search API Solr. 9 | 10 | SOLR_SETUP_COMPLETE_FILE=/etc/drupal_vm_solr_config_complete 11 | 12 | # Search API Solr module. 13 | SOLR_DOWNLOAD=http://ftp.drupal.org/files/projects/search_api_solr-8.x-1.x-dev.tar.gz 14 | SOLR_DOWNLOAD_DIR=/tmp 15 | SOLR_MODULE_NAME=search_api_solr 16 | 17 | # Check to see if we've already performed this setup. 18 | if [ ! -e "$SOLR_SETUP_COMPLETE_FILE" ]; then 19 | # Download and expand the Solr module. 20 | wget -qO- $SOLR_DOWNLOAD | tar xvz -C $SOLR_DOWNLOAD_DIR 21 | 22 | # Copy the Solr configuration into place over the default `collection1` core. 23 | sudo cp -a $SOLR_DOWNLOAD_DIR/$SOLR_MODULE_NAME/solr-conf/4.x/. /var/solr/collection1/conf/ 24 | 25 | # Adjust the autoCommit time so index changes are committed in 1s. 26 | sudo sed -i 's/\(<maxTime>\)\([^<]*\)\(<[^>]*\)/\11000\3/g' /var/solr/collection1/conf/solrconfig.xml 27 | 28 | # Fix file permissions. 29 | sudo chown -R solr:solr /var/solr/collection1/conf 30 | 31 | # Restart Apache Solr. 32 | sudo service solr restart 33 | 34 | # Create a file to indicate this script has already run. 35 | sudo touch $SOLR_SETUP_COMPLETE_FILE 36 | else 37 | exit 0 38 | fi 39 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Drupal VM Documentation 2 | 3 | repo_url: https://github.com/geerlingguy/drupal-vm 4 | site_description: 'Drupal VM - A VM for local Drupal development, built with Vagrant + Ansible' 5 | theme: readthedocs 6 | 7 | markdown_extensions: 8 | - toc: 9 | permalink: True 10 | 11 | pages: 12 | - Home: 'index.md' 13 | - Drupal Deployment Strategies: 14 | - 'Drush Make file': 'deployment/drush-make.md' 15 | - 'Local Drupal codebase': 'deployment/local-codebase.md' 16 | - 'Drupal multisite': 'deployment/multisite.md' 17 | - Extra Software and Setup: 18 | - 'Syncing Folders': 'extras/syncing-folders.md' 19 | - 'Connect to the MySQL Database': 'extras/mysql.md' 20 | - 'Use Apache Solr for Search': 'extras/solr.md' 21 | - 'Use Drush with Drupal VM': 'extras/drush.md' 22 | - 'Use Drupal Console with Drupal VM': 'extras/drupal-console.md' 23 | - 'Use Varnish with Drupal VM': 'extras/varnish.md' 24 | - 'Use MariaDB instead of MySQL': 'extras/mariadb.md' 25 | - 'Use Node.js and NPM': 'extras/nodejs.md' 26 | - 'Use SSL vhosts with Apache': 'extras/ssl.md' 27 | - 'View Logs with Pimp my Log': 'extras/pimpmylog.md' 28 | - 'Profile Code with XHProf': 'extras/xhprof.md' 29 | - 'Debug Code with XDebug': 'extras/xdebug.md' 30 | - 'Catch Emails with MailHog': 'extras/mailhog.md' 31 | - 'Test with Behat and Selenium': 'extras/behat.md' 32 | - 'Add Post-Provision Scripts': 'extras/scripts.md' 33 | - Other Information: 34 | - 'Using Different Base OSes': 'other/base-os.md' 35 | - 'Using Different Webservers': 'other/webservers.md' 36 | - 'Using a local Vagrantfile': 'other/local-vagrantfile.md' 37 | - 'PHP 7 on Drupal VM': 'other/php-7.md' 38 | - 'BigPipe with Drupal VM': 'other/bigpipe.md' 39 | - 'Drupal VM Management Tools': 'other/management-tools.md' 40 | - 'Networking Notes': 'other/networking.md' 41 | - 'Drupal 6 Notes': 'other/drupal-6.md' 42 | - 'Linux Notes': 'other/linux.md' 43 | - 'Windows Notes': 'other/windows.md' 44 | - 'Vagrant and VirtualBox Tips': 'other/vagrant-virtualbox.md' 45 | -------------------------------------------------------------------------------- /provisioning/JJG-Ansible-Windows/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Jeff Geerling 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /provisioning/JJG-Ansible-Windows/README.md: -------------------------------------------------------------------------------- 1 | # JJG-Ansible-Windows 2 | 3 | > **Important Note**: Vagrant now includes an [`ansible_local` provisioner](https://docs.vagrantup.com/v2/provisioning/ansible_local.html), which provides a much more reliable Ansible provisioning experience within a Vagrant VM. This project will likely no longer be updated for use beyond Vagrant 1.7.x. 4 | 5 | Windows shell provisioning script to bootstrap Ansible from within a Vagrant VM running on Windows. 6 | 7 | This script is configured to use configure any Linux-based VM (Debian, Ubuntu, Fedora, RedHat, CentOS, etc.) so it can run Ansible playbooks from within the VM through Vagrant. 8 | 9 | Read more about this script, and other techniques for using Ansible within a Windows environment, on Server Check.in: [Running Ansible within Windows](https://servercheck.in/blog/running-ansible-within-windows). 10 | 11 | ## Usage 12 | 13 | In your Vagrantfile, use a conditional provisioning statement if you want to use this script (which runs Ansible from within the VM instead of on your host—this example assumes your playbook is inside within a 'provisioning' folder, and this script is within provisioning/JJG-Ansible-Windows): 14 | 15 | ```ruby 16 | # Use rbconfig to determine if we're on a windows host or not. 17 | require 'rbconfig' 18 | is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) 19 | if is_windows 20 | # Provisioning configuration for shell script. 21 | config.vm.provision "shell" do |sh| 22 | sh.path = "provisioning/JJG-Ansible-Windows/windows.sh" 23 | sh.args = "provisioning/playbook.yml" 24 | end 25 | else 26 | # Provisioning configuration for Ansible (for Mac/Linux hosts). 27 | config.vm.provision "ansible" do |ansible| 28 | ansible.playbook = "provisioning/playbook.yml" 29 | ansible.sudo = true 30 | end 31 | end 32 | ``` 33 | 34 | Note that the `windows.sh` script will run within the VM and will run the given playbook against localhost with `--connection=local` inside the VM. You shouldn't/can't pass a custom inventory file to the script, as you can using Vagrant's Ansible provisioner. 35 | 36 | ### Role Requirements File 37 | 38 | If your playbook requires roles to be installed which are not present in a `roles` directory within the playbook's directory, then you should add the roles to a [role requirements](http://docs.ansible.com/galaxy.html#advanced-control-over-role-requirements-files) file. Place the resulting `requirements.txt` or `requirements.yml` file in the same directory as your playbook, and the roles will be installed automatically. 39 | 40 | ## Licensing and More Info 41 | 42 | Created by [Jeff Geerling](http://jeffgeerling.com/) in 2014. Licensed under the MIT license; see the LICENSE file for more info. 43 | -------------------------------------------------------------------------------- /provisioning/JJG-Ansible-Windows/windows.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Windows shell provisioner for Ansible playbooks, based on KSid's 4 | # windows-vagrant-ansible: https://github.com/KSid/windows-vagrant-ansible 5 | # 6 | # @see README.md 7 | # @author Jeff Geerling, 2014 8 | 9 | # Uncomment if behind a proxy server. 10 | # export {http,https,ftp}_proxy='http://username:password@proxy-host:80' 11 | 12 | ANSIBLE_PLAYBOOK=$1 13 | PLAYBOOK_DIR=${ANSIBLE_PLAYBOOK%/*} 14 | 15 | # Detect package management system. 16 | YUM=$(which yum 2>/dev/null) 17 | APT_GET=$(which apt-get 2>/dev/null) 18 | 19 | # Make sure Ansible playbook exists. 20 | if [ ! -f "/vagrant/$ANSIBLE_PLAYBOOK" ]; then 21 | echo "Cannot find Ansible playbook." 22 | exit 1 23 | fi 24 | 25 | # Install Ansible and its dependencies if it's not installed already. 26 | if ! command -v ansible >/dev/null; then 27 | echo "Installing Ansible dependencies and Git." 28 | if [[ ! -z ${YUM} ]]; then 29 | yum install -y git python python-devel 30 | elif [[ ! -z ${APT_GET} ]]; then 31 | apt-get update 32 | apt-get install -y git python python-dev 33 | else 34 | echo "Neither yum nor apt-get are available." 35 | exit 1; 36 | fi 37 | 38 | echo "Installing pip via easy_install." 39 | wget https://raw.githubusercontent.com/ActiveState/ez_setup/v0.9/ez_setup.py 40 | python ez_setup.py && rm -f ez_setup.py 41 | easy_install pip 42 | 43 | # Make sure setuptools are installed crrectly. 44 | pip install setuptools --no-use-wheel --upgrade 45 | 46 | # Install GCC / required build tools. 47 | if [[ ! -z $YUM ]]; then 48 | yum install -y gcc 49 | elif [[ ! -z $APT_GET ]]; then 50 | apt-get install -y build-essential 51 | fi 52 | 53 | echo "Installing required python modules." 54 | pip install paramiko pyyaml jinja2 markupsafe 55 | 56 | echo "Installing Ansible." 57 | pip install ansible 58 | fi 59 | 60 | # Install requirements. 61 | echo "Installing Ansible roles from requirements file, if available." 62 | find "/vagrant/$PLAYBOOK_DIR" \( -name "requirements.yml" -o -name "requirements.txt" \) -exec sudo ansible-galaxy install --ignore-errors -r {} \; 63 | 64 | # Run the playbook. 65 | echo "Running Ansible provisioner defined in Vagrantfile." 66 | ansible-playbook -i 'localhost,' "/vagrant/${ANSIBLE_PLAYBOOK}" --extra-vars "is_windows=true" --connection=local 67 | -------------------------------------------------------------------------------- /provisioning/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | become: yes 4 | 5 | vars_files: 6 | - vars/main.yml 7 | - ../config.yml 8 | 9 | pre_tasks: 10 | - include: tasks/init-debian.yml 11 | when: ansible_os_family == 'Debian' 12 | - include: tasks/init-redhat.yml 13 | when: ansible_os_family == 'RedHat' 14 | 15 | - name: Set the PHP webserver daemon correctly when nginx is in use. 16 | set_fact: 17 | php_webserver_daemon: nginx 18 | when: drupalvm_webserver == 'nginx' 19 | 20 | roles: 21 | # Essential roles. 22 | - { role: geerlingguy.repo-remi, when: ansible_os_family == 'RedHat' } 23 | - geerlingguy.firewall 24 | - geerlingguy.git 25 | - geerlingguy.postfix 26 | - { role: geerlingguy.apache, when: drupalvm_webserver == 'apache' } 27 | - { role: geerlingguy.apache-php-fpm, when: drupalvm_webserver == 'apache' } 28 | - { role: geerlingguy.nginx, when: drupalvm_webserver == 'nginx' } 29 | - geerlingguy.mysql 30 | - geerlingguy.php 31 | - geerlingguy.php-pecl 32 | - geerlingguy.php-mysql 33 | - geerlingguy.composer 34 | - geerlingguy.drush 35 | 36 | # Conditionally-installed roles. 37 | - { role: geerlingguy.drupal-console, when: 'drupal_major_version > 7 and "drupalconsole" in installed_extras' } 38 | - { role: geerlingguy.memcached, when: '"memcached" in installed_extras' } 39 | - { role: geerlingguy.php-memcached, when: '"memcached" in installed_extras' } 40 | - { role: geerlingguy.php-xdebug, when: '"xdebug" in installed_extras' } 41 | - { role: geerlingguy.php-xhprof, when: '"xhprof" in installed_extras' } 42 | - { role: geerlingguy.adminer, when: '"adminer" in installed_extras' } 43 | - { role: geerlingguy.pimpmylog, when: '"pimpmylog" in installed_extras' } 44 | - { role: geerlingguy.daemonize, when: '"mailhog" in installed_extras' } 45 | - { role: geerlingguy.mailhog, when: '"mailhog" in installed_extras' } 46 | - { role: geerlingguy.nodejs, when: '"nodejs" in installed_extras' } 47 | - { role: geerlingguy.redis, when: '"redis" in installed_extras' } 48 | - { role: geerlingguy.php-redis, when: '"redis" in installed_extras' } 49 | - { role: geerlingguy.ruby, when: '"ruby" in installed_extras' } 50 | - { role: geerlingguy.java, when: '"solr" in installed_extras or "selenium" in installed_extras' } 51 | - { role: arknoll.selenium, when: '"selenium" in installed_extras' } 52 | - { role: geerlingguy.solr, when: '"solr" in installed_extras' } 53 | - { role: geerlingguy.varnish, when: '"varnish" in installed_extras' } 54 | 55 | # Roles for security and stability on production. 56 | - { role: geerlingguy.security, when: extra_security_enabled } 57 | 58 | tasks: 59 | - name: Check if Drupal is already set up. 60 | stat: "path={{ drupal_core_path }}/index.php" 61 | register: drupal_site 62 | 63 | - include: tasks/sshd.yml 64 | - include: tasks/extras.yml 65 | - include: tasks/www.yml 66 | - include: tasks/apparmor.yml 67 | when: ansible_os_family == 'Debian' 68 | 69 | # Build makefile if configured. 70 | - include: tasks/build-makefile.yml 71 | when: build_makefile 72 | 73 | # Install site if configured. 74 | - include: tasks/install-site.yml 75 | when: install_site 76 | 77 | - include: tasks/drush-aliases.yml 78 | - include: tasks/cron.yml 79 | 80 | - include: tasks/dashboard.yml 81 | when: dashboard_install_dir is defined and dashboard_install_dir != '' 82 | 83 | - name: Run configured post-provision shell scripts. 84 | script: "{{ item }}" 85 | with_items: "{{ post_provision_scripts }}" 86 | when: post_provision_scripts is defined 87 | -------------------------------------------------------------------------------- /provisioning/requirements.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - src: arknoll.selenium 3 | - src: geerlingguy.adminer 4 | - src: geerlingguy.apache 5 | - src: geerlingguy.apache-php-fpm 6 | - src: geerlingguy.composer 7 | - src: geerlingguy.daemonize 8 | - src: geerlingguy.drupal-console 9 | - src: geerlingguy.drush 10 | - src: geerlingguy.firewall 11 | - src: geerlingguy.git 12 | - src: geerlingguy.java 13 | - src: geerlingguy.mailhog 14 | - src: geerlingguy.memcached 15 | - src: geerlingguy.mysql 16 | - src: geerlingguy.nginx 17 | - src: geerlingguy.nodejs 18 | - src: geerlingguy.php 19 | - src: geerlingguy.php-memcached 20 | - src: geerlingguy.php-mysql 21 | - src: geerlingguy.php-pecl 22 | - src: geerlingguy.php-redis 23 | - src: geerlingguy.php-xdebug 24 | - src: geerlingguy.php-xhprof 25 | - src: geerlingguy.pimpmylog 26 | - src: geerlingguy.postfix 27 | - src: geerlingguy.redis 28 | - src: geerlingguy.repo-remi 29 | - src: geerlingguy.ruby 30 | - src: geerlingguy.security 31 | - src: geerlingguy.solr 32 | - src: geerlingguy.varnish 33 | -------------------------------------------------------------------------------- /provisioning/tasks/apparmor.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Detect if AppArmor is installed. 3 | stat: 4 | path: /etc/init.d/apparmor 5 | register: apparmor_installed 6 | 7 | - name: Ensure MySQL AppArmor profile is disabled (for slow query log). 8 | file: 9 | path: /etc/apparmor.d/disable/usr.sbin.mysqld 10 | src: /etc/apparmor.d/usr.sbin.mysqld 11 | state: link 12 | register: mysql_apparmor 13 | when: mysql_slow_query_log_enabled and apparmor_installed.stat.exists 14 | 15 | - name: Restart the AppArmor if necessary. 16 | service: name=apparmor state=restarted 17 | when: mysql_apparmor.changed 18 | -------------------------------------------------------------------------------- /provisioning/tasks/build-makefile.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Copy drush makefile into place. 3 | copy: 4 | src: "{{ drush_makefile_path }}" 5 | dest: /tmp/drupal.make.yml 6 | when: drupal_site.stat.exists == false 7 | 8 | - name: Ensure drupal_core_path directory exists. 9 | file: 10 | path: "{{ drupal_core_path }}" 11 | state: directory 12 | recurse: yes 13 | mode: 0775 14 | become: no 15 | when: drupal_site.stat.exists == false 16 | 17 | - name: Generate Drupal site with drush makefile. 18 | command: > 19 | {{ drush_path }} make -y /tmp/drupal.make.yml --no-gitinfofile 20 | chdir={{ drupal_core_path }} 21 | when: drupal_site.stat.exists == false 22 | become: no 23 | 24 | - name: Check if a composer.json file is present. 25 | stat: "path={{ drupal_core_path }}/composer.json" 26 | register: drupal_core_composer_file 27 | when: drupal_site.stat.exists == false 28 | 29 | - name: Run composer install if composer.json is present. 30 | command: > 31 | composer install 32 | chdir={{ drupal_core_path }} 33 | when: drupal_site.stat.exists == false and drupal_core_composer_file.stat.exists == true 34 | become: no 35 | -------------------------------------------------------------------------------- /provisioning/tasks/cron.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure configured cron jobs exist in root account's crontab. 3 | cron: 4 | name: "{{ item.name }}" 5 | minute: "{{ item.minute | default('*') }}" 6 | hour: "{{ item.hour | default('*') }}" 7 | day: "{{ item.day | default('*') }}" 8 | weekday: "{{ item.weekday | default('*') }}" 9 | month: "{{ item.month | default('*') }}" 10 | job: "{{ item.job }}" 11 | state: "{{ item.state | default('present') }}" 12 | with_items: "{{ drupalvm_cron_jobs }}" 13 | when: drupalvm_cron_jobs is defined 14 | -------------------------------------------------------------------------------- /provisioning/tasks/dashboard.yml: -------------------------------------------------------------------------------- 1 | - name: Ensure the dashboard directory exists 2 | file: 3 | path: "{{ dashboard_install_dir }}" 4 | state: directory 5 | mode: 0755 6 | 7 | - name: Copy dashboard page into place. 8 | template: 9 | src: ../templates/dashboard.html.j2 10 | dest: "{{ dashboard_install_dir }}/index.html" 11 | mode: 0644 12 | -------------------------------------------------------------------------------- /provisioning/tasks/drush-aliases.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Check if local Drush configuration folder exists. 3 | stat: 4 | path: ~/.drush 5 | register: local_drush_config_folder 6 | delegate_to: 127.0.0.1 7 | become: no 8 | when: configure_local_drush_aliases 9 | 10 | - name: Create Drush configuration folder if it doesn't exist. 11 | file: 12 | path: ~/.drush 13 | state: directory 14 | delegate_to: 127.0.0.1 15 | become: no 16 | when: configure_local_drush_aliases and (local_drush_config_folder.stat.exists == false) 17 | 18 | # Note that this doesn't work for Windows, since Ansible's running in the VM. 19 | - name: Configure host machine drush aliases. 20 | template: 21 | src: ../templates/drupalvm.aliases.drushrc.php.j2 22 | dest: "~/.drush/{{ vagrant_machine_name }}.aliases.drushrc.php" 23 | delegate_to: 127.0.0.1 24 | become: no 25 | when: configure_local_drush_aliases 26 | 27 | - name: Ensure drush directory exists for vagrant user inside VM. 28 | file: 'path="~/.drush" state=directory' 29 | become: no 30 | 31 | - name: Configure drush aliases for vagrant user inside VM. 32 | template: 33 | src: ../templates/drupalvm-local.aliases.drushrc.php.j2 34 | dest: "~/.drush/{{ vagrant_machine_name }}.aliases.drushrc.php" 35 | become: no 36 | 37 | - name: Ensure drush directory exists for root user inside VM. 38 | file: 'path="~/.drush" state=directory' 39 | 40 | - name: Configure drush aliases for root user inside VM. 41 | template: 42 | src: ../templates/drupalvm-local.aliases.drushrc.php.j2 43 | dest: "~/.drush/{{ vagrant_machine_name }}.aliases.drushrc.php" 44 | -------------------------------------------------------------------------------- /provisioning/tasks/extras.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install extra apt packages (if any are configured). 3 | apt: "name={{ item }} state=installed" 4 | with_items: "{{ extra_packages | list }}" 5 | when: ansible_os_family == 'Debian' and extra_packages | length 6 | 7 | - name: Install extra yum packages (if any are configured). 8 | yum: "name={{ item }} state=installed" 9 | with_items: "{{ extra_packages | list }}" 10 | when: ansible_os_family == 'RedHat' and extra_packages | length 11 | -------------------------------------------------------------------------------- /provisioning/tasks/init-debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Update apt cache if needed. 3 | apt: update_cache=yes cache_valid_time=86400 4 | 5 | - name: Get software for Python-based control. 6 | apt: "name={{ item }} state=installed" 7 | with_items: 8 | - curl 9 | - python-apt 10 | - python-pycurl 11 | - build-essential 12 | - unzip 13 | 14 | - name: Disable the ufw firewall (since we use a simple iptables firewall). 15 | service: name=ufw state=stopped 16 | when: ansible_distribution == "Ubuntu" 17 | 18 | - name: Add repository for PHP 5.5. 19 | apt_repository: repo='ppa:ondrej/php5' 20 | when: php_version == "5.5" and ansible_distribution == "Ubuntu" 21 | 22 | - name: Add repository for PHP 5.6. 23 | apt_repository: repo='ppa:ondrej/php5-5.6' 24 | when: php_version == "5.6" and ansible_distribution == "Ubuntu" 25 | 26 | - name: Add repository for PHP 7.0. 27 | apt_repository: repo='ppa:ondrej/php' 28 | when: php_version == "7.0" and ansible_distribution == "Ubuntu" 29 | 30 | - name: Define php_xhprof_html_dir. 31 | set_fact: 32 | php_xhprof_html_dir: "/usr/share/php/xhprof_html" 33 | when: php_xhprof_html_dir is not defined 34 | -------------------------------------------------------------------------------- /provisioning/tasks/init-redhat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Get software for Python-based control. 3 | yum: "name={{ item }} state=installed" 4 | with_items: 5 | - "curl" 6 | - "python-pycurl" 7 | - "@development" 8 | - "unzip" 9 | 10 | - name: Enable remi repo for MySQL. 11 | set_fact: mysql_enablerepo="remi" 12 | 13 | - name: Enable remi repo for PHP 5.5. 14 | set_fact: php_enablerepo="remi,remi-php55" 15 | when: php_version == "5.5" 16 | 17 | - name: Enable remi repo for PHP 5.6. 18 | set_fact: php_enablerepo="remi,remi-php56" 19 | when: php_version == "5.6" 20 | 21 | - name: Enable remi repo for PHP 7.0. 22 | set_fact: php_enablerepo="remi,remi-php70" 23 | when: php_version == "7.0" 24 | 25 | - name: Define php_xhprof_html_dir. 26 | set_fact: 27 | php_xhprof_html_dir: "/usr/share/pear/xhprof_html" 28 | when: php_xhprof_html_dir is not defined 29 | -------------------------------------------------------------------------------- /provisioning/tasks/install-site.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Check if site is already installed. 3 | command: > 4 | {{ drush_path }} status bootstrap 5 | chdir={{ drupal_core_path }} 6 | register: drupal_site_installed 7 | failed_when: false 8 | changed_when: false 9 | become: no 10 | 11 | - name: Install Drupal with drush. 12 | command: > 13 | {{ drush_path }} site-install {{ drupal_install_profile | default('standard') }} -y 14 | --site-name="{{ drupal_site_name }}" 15 | --account-name={{ drupal_account_name }} 16 | --account-pass={{ drupal_account_pass }} 17 | --db-url=mysql://{{ drupal_mysql_user }}:{{ drupal_mysql_password }}@localhost/{{ mysql_databases[0].name }} 18 | {{ drupal_site_install_extra_args | default([]) | join(" ") }} 19 | chdir={{ drupal_core_path }} 20 | notify: restart webserver 21 | when: "'Successful' not in drupal_site_installed.stdout" 22 | become: no 23 | 24 | - name: Install configured modules with drush. 25 | command: > 26 | {{ drush_path }} pm-enable -y {{ drupal_enable_modules | join(" ") }} 27 | chdir={{ drupal_core_path }} 28 | when: "'Successful' not in drupal_site_installed.stdout" 29 | become: no 30 | -------------------------------------------------------------------------------- /provisioning/tasks/sshd.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Do not accept locale environment variables passed over SSH. 3 | lineinfile: 4 | dest: /etc/ssh/sshd_config 5 | regexp: "^AcceptEnv LANG" 6 | state: absent 7 | validate: "/usr/sbin/sshd -T -f %s" 8 | 9 | - name: Check if local known_hosts file is present. 10 | stat: "path={{ known_hosts_path | default('~/.ssh/known_hosts') }}" 11 | register: known_hosts_file 12 | connection: local 13 | become: no 14 | 15 | - name: Copy known_hosts file from host into Drupal VM. 16 | copy: 17 | src: "{{ known_hosts_path | default('~/.ssh/known_hosts') }}" 18 | dest: ~/.ssh/known_hosts 19 | mode: 0644 20 | become: no 21 | when: known_hosts_file.stat.exists 22 | -------------------------------------------------------------------------------- /provisioning/tasks/www.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Originally I tried adding to the www group, but because Ansible uses one SSH 3 | # connection, that broke the initial provisioning, since groups aren't refreshed 4 | # without a new session or log off/log on. 5 | - name: Ensure necessary groups exist. 6 | group: "name={{ item }} state=present" 7 | with_items: 8 | - admin 9 | - dialout 10 | 11 | - name: Ensure vagrant user is in admin group. 12 | user: "name={{ vagrant_user }} append=yes groups=admin" 13 | 14 | - name: Ensure www-data user is in dialout group (Debian). 15 | user: "name=www-data append=yes groups=dialout" 16 | when: ansible_os_family == 'Debian' 17 | 18 | - name: Set nicer permissions on Apache log directory. 19 | file: 20 | path: "/var/log/{{ apache_daemon }}" 21 | state: directory 22 | mode: 0755 23 | recurse: true 24 | when: drupalvm_webserver == 'apache' 25 | 26 | - name: Copy Nginx vhosts into place. 27 | template: 28 | src: ../templates/nginx-vhost.conf.j2 29 | dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf" 30 | force: yes 31 | owner: root 32 | group: root 33 | mode: 0644 34 | with_items: "{{ nginx_hosts }}" 35 | notify: restart nginx 36 | when: drupalvm_webserver == 'nginx' 37 | -------------------------------------------------------------------------------- /provisioning/templates/dashboard.html.j2: -------------------------------------------------------------------------------- 1 | <!DOCTYPE html> 2 | <head> 3 | <title>Drupal VM 4 | 5 | 20 | 21 | 22 | {# Returns the hosts server name based on the document root #} 23 | {%- macro getServernameFromDocroot(path) -%} 24 | {%- if drupalvm_webserver == 'apache' -%} 25 | {%- for host in apache_vhosts -%} 26 | {%- if host.documentroot == path -%} 27 | {{ host.servername }} 28 | {%- endif -%} 29 | {%- endfor -%} 30 | {%- elif drupalvm_webserver == 'nginx' -%} 31 | {%- for host in nginx_hosts -%} 32 | {%- if host.root == path -%} 33 | {{ host.server_name }} 34 | {%- endif -%} 35 | {%- endfor -%} 36 | {%- endif -%} 37 | {%- endmacro -%} 38 | 39 | {%- macro printSite(servername, docroot) -%} 40 | {%- if docroot not in _devtool_docroots -%} 41 | 42 | {{ servername }} 43 | {{ docroot }} 44 | {% if configure_local_drush_aliases %} 45 | drush @{{ vagrant_machine_name }}.{{ servername }} 46 | {% endif %} 47 | 48 | {% endif %} 49 | {%- endmacro %} 50 | 51 | {%- macro printHostsEntry(ip, servername) -%} 52 | {%- if servername != ip -%} 53 |
  • {{ ip }} {{ servername }}
  • 54 | {%- endif -%} 55 | {%- endmacro %} 56 | 57 | {%- macro sectionHost() -%} 58 | 85 | {%- endmacro -%} 86 | 87 | {%- macro sectionSiteList() -%} 88 | 89 | 90 | 91 | 92 | 93 | {% if configure_local_drush_aliases -%} 94 | 95 | {%- endif %} 96 | 97 | 98 | {% if drupalvm_webserver == 'apache' -%} 99 | {%- for host in apache_vhosts -%} 100 | {{ printSite(host.servername, host.documentroot) }} 101 | {%- endfor -%} 102 | {%- elif drupalvm_webserver == 'nginx' -%} 103 | {%- for host in nginx_hosts -%} 104 | {{ printSite(host.server_name, host.root) }} 105 | {%- endfor -%} 106 | {%- endif %} 107 | 108 | 109 |
    HostnameDocument RootDrush alias*
    *Note: On Windows or when you don't have Ansible installed on your host, Drush aliases are only created inside the VM.
    110 | {%- endmacro -%} 111 | 112 | {%- macro sectionDevelopmentTools() -%} 113 | 114 | {% if 'adminer' in installed_extras -%} 115 | {% macro servername() %}{{ getServernameFromDocroot(adminer_install_dir) }}/{{ adminer_install_filename }}{% endmacro %} 116 | {%- if servername() != "/{{ adminer_install_filename }}" -%} 117 | 118 | 119 | 120 | 124 | 125 | {%- endif -%} 126 | {%- endif %} 127 | {% if 'mailhog' in installed_extras -%} 128 | {% macro servername() %}{{ vagrant_hostname }}:8025{% endmacro %} 129 | {%- if servername() != ":8025" -%} 130 | 131 | 132 | 133 | 137 | 138 | {%- endif -%} 139 | {%- endif %} 140 | {% if 'pimpmylog' in installed_extras -%} 141 | {% macro servername() %}{{ getServernameFromDocroot(pimpmylog_install_dir) }}{% endmacro %} 142 | {%- if servername() -%} 143 | 144 | 145 | 146 | 150 | 151 | {%- endif -%} 152 | {%- endif %} 153 | {% if 'solr' in installed_extras -%} 154 | {% macro servername() %}{{ vagrant_hostname }}:{{ solr_port }}/solr/{% endmacro %} 155 | 156 | 157 | 158 | 162 | 163 | {%- endif %} 164 | {% if 'xhprof' in installed_extras -%} 165 | {% macro servername() %}{{ getServernameFromDocroot(php_xhprof_html_dir) }}{% endmacro %} 166 | {%- if servername() -%} 167 | 168 | 169 | 170 | 174 | 175 | {%- endif -%} 176 | {%- endif %} 177 |
    Adminer{{ servername() }} 121 | Open 122 | Documentation 123 |
    MailHog{{ servername() }} 134 | Open 135 | Documentation 136 |
    PimpMyLog{{ servername() }} 147 | Open 148 | Documentation 149 |
    Solr{{ servername() }} 159 | Open 160 | Documentation 161 |
    XHProf{{ servername() }} 171 | Open 172 | Documentation 173 |
    178 | {%- endmacro -%} 179 | 180 | {%- macro sectionDatabaseConnection() -%} 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 |
    MySQL Hostname127.0.0.1
    MySQL Port{{ mysql_port }}
    MySQL Username{{ mysql_root_username }}
    MySQL Password{{ mysql_root_password }}
    SSH Hostname{{ vagrant_ip }}
    SSH Username{{ vagrant_user }}
    SSH Private Key~/.vagrant.d/insecure_private_key
    211 | {%- endmacro -%} 212 | 213 | {%- macro sectionDatabaseList() -%} 214 | 215 | 216 | 217 | 218 | {% if 'adminer' in installed_extras -%} 219 | 220 | {%- endif %} 221 | 222 | 223 | 224 | {% for database in mysql_databases -%} 225 | 226 | 227 | {% if 'adminer' in installed_extras -%} 228 | 231 | {%- endif %} 232 | 233 | {%- endfor %} 234 | 235 |
    Database name
    {{ database.name }} 229 | Adminer 230 |
    236 | {%- endmacro -%} 237 | 238 | {%- macro sectionDatabaseUserList() -%} 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | {% for user in mysql_users -%} 248 | 249 | 250 | 251 | 252 | {%- endfor %} 253 | 254 |
    UsernamePassword
    {{ user.name }}{{ user.password }}
    255 | {%- endmacro -%} 256 | 257 |
    258 | 259 |
    260 |
    261 |
    262 |
    263 |
    264 | Drupal VM 265 |

    Drupal VM is a VM for local Drupal development, built with Vagrant + Ansible.

    266 |

    Read the documentation

    267 |
    268 | 269 |
    270 |
    /etc/hosts
    271 |
    272 | {{ sectionHost() }} 273 |
    274 | Unless you're using the vagrant-hostsupdater or vagrant-hostmanager plugin, add the lines above to your host machine's hosts file. 275 |
    276 |
    277 |
    278 |
    279 |
    280 | 281 |
    282 |
    283 | 284 |
    285 |
    Your sites
    286 |
    287 | {{ sectionSiteList() }} 288 |
    289 |
    290 | 291 |
    292 |
    Development tools
    293 |
    294 | {{ sectionDevelopmentTools() }} 295 |
    296 |
    297 |
    298 | 299 |
    300 |
    301 |
    MySQL connection information
    302 |
    303 | {{ sectionDatabaseConnection() }} 304 |
    305 |
    306 | 307 |
    308 |
    Databases
    309 |
    310 | {{ sectionDatabaseList() }} 311 | 312 | {{ sectionDatabaseUserList() }} 313 |
    314 |
    315 |
    316 |
    317 | 318 |
    319 | 320 | 321 | 322 | 323 | -------------------------------------------------------------------------------- /provisioning/templates/drupalvm-local.aliases.drushrc.php.j2: -------------------------------------------------------------------------------- 1 | '{{ host }}', 13 | 'root' => '{{ root }}', 14 | ); 15 | 16 | {% endif -%} 17 | {% endmacro %} 18 | 19 | {%- if drupalvm_webserver == 'apache' -%} 20 | {%- for vhost in apache_vhosts -%} 21 | {{ alias(vhost.servername, vhost.documentroot) }} 22 | {%- if vhost.serveralias is defined -%} 23 | {%- for serveralias in vhost.serveralias.split() -%} 24 | {{ alias(serveralias, vhost.documentroot) }} 25 | {%- endfor -%} 26 | {%- endif -%} 27 | {%- endfor -%} 28 | {%- elif drupalvm_webserver == 'nginx' -%} 29 | {%- for host in nginx_hosts -%} 30 | {%- for server_name in host.server_name.split() -%} 31 | {{ alias(server_name, host.root) }} 32 | {%- endfor -%} 33 | {%- endfor -%} 34 | {%- endif -%} 35 | -------------------------------------------------------------------------------- /provisioning/templates/drupalvm.aliases.drushrc.php.j2: -------------------------------------------------------------------------------- 1 | '{{ host }}', 13 | 'root' => '{{ root }}', 14 | 'remote-host' => '{{ host }}', 15 | 'remote-user' => '{{ vagrant_user }}', 16 | 'ssh-options' => '-o PasswordAuthentication=no -i ' . drush_server_home() . '/.vagrant.d/insecure_private_key', 17 | ); 18 | 19 | {% endif -%} 20 | {% endmacro %} 21 | 22 | {%- if drupalvm_webserver == 'apache' -%} 23 | {%- for vhost in apache_vhosts -%} 24 | {{ alias(vhost.servername, vhost.documentroot) }} 25 | {%- if vhost.serveralias is defined -%} 26 | {%- for serveralias in vhost.serveralias.split() -%} 27 | {{ alias(serveralias, vhost.documentroot) }} 28 | {%- endfor -%} 29 | {%- endif -%} 30 | {%- endfor -%} 31 | {%- elif drupalvm_webserver == 'nginx' -%} 32 | {%- for host in nginx_hosts -%} 33 | {%- for server_name in host.server_name.split() -%} 34 | {{ alias(server_name, host.root) }} 35 | {%- endfor -%} 36 | {%- endfor -%} 37 | {%- endif -%} 38 | -------------------------------------------------------------------------------- /provisioning/templates/drupalvm.vcl.j2: -------------------------------------------------------------------------------- 1 | vcl 4.0; 2 | 3 | # This Varnish VCL has been adapted from the Four Kitchens VCL for Varnish 3. 4 | 5 | # Default backend definition. Points to Apache, normally. 6 | backend default { 7 | .host = "{{ varnish_default_backend_host }}"; 8 | .port = "{{ varnish_default_backend_port }}"; 9 | .first_byte_timeout = 300s; 10 | } 11 | 12 | # Access control list for PURGE requests. 13 | acl purge { 14 | "127.0.0.1"; 15 | } 16 | 17 | # Respond to incoming requests. 18 | sub vcl_recv { 19 | # Add an X-Forwarded-For header with the client IP address. 20 | if (req.restarts == 0) { 21 | if (req.http.X-Forwarded-For) { 22 | set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip; 23 | } 24 | else { 25 | set req.http.X-Forwarded-For = client.ip; 26 | } 27 | } 28 | 29 | # Only allow PURGE requests from IP addresses in the 'purge' ACL. 30 | if (req.method == "PURGE") { 31 | if (!client.ip ~ purge) { 32 | return (synth(405, "Not allowed.")); 33 | } 34 | return (hash); 35 | } 36 | 37 | # Only allow BAN requests from IP addresses in the 'purge' ACL. 38 | if (req.method == "BAN") { 39 | # Same ACL check as above: 40 | if (!client.ip ~ purge) { 41 | return (synth(403, "Not allowed.")); 42 | } 43 | 44 | # Logic for the ban, using the Purge-Cache-Tags header. For more info 45 | # see https://github.com/geerlingguy/drupal-vm/issues/397. 46 | if (req.http.Purge-Cache-Tags) { 47 | ban("obj.http.Purge-Cache-Tags ~ " + req.http.Purge-Cache-Tags); 48 | } 49 | else { 50 | return (synth(403, "Purge-Cache-Tags header missing.")); 51 | } 52 | 53 | # Throw a synthetic page so the request won't go to the backend. 54 | return (synth(200, "Ban added.")); 55 | } 56 | 57 | # Only cache GET and HEAD requests (pass through POST requests). 58 | if (req.method != "GET" && req.method != "HEAD") { 59 | return (pass); 60 | } 61 | 62 | # Pass through any administrative or AJAX-related paths. 63 | if (req.url ~ "^/status\.php$" || 64 | req.url ~ "^/update\.php$" || 65 | req.url ~ "^/admin$" || 66 | req.url ~ "^/admin/.*$" || 67 | req.url ~ "^/flag/.*$" || 68 | req.url ~ "^.*/ajax/.*$" || 69 | req.url ~ "^.*/ahah/.*$") { 70 | return (pass); 71 | } 72 | 73 | # Removing cookies for static content so Varnish caches these files. 74 | if (req.url ~ "(?i)\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js)(\?.*)?$") { 75 | unset req.http.Cookie; 76 | } 77 | 78 | # Remove all cookies that Drupal doesn't need to know about. We explicitly 79 | # list the ones that Drupal does need, the SESS and NO_CACHE. If, after 80 | # running this code we find that either of these two cookies remains, we 81 | # will pass as the page cannot be cached. 82 | if (req.http.Cookie) { 83 | # 1. Append a semi-colon to the front of the cookie string. 84 | # 2. Remove all spaces that appear after semi-colons. 85 | # 3. Match the cookies we want to keep, adding the space we removed 86 | # previously back. (\1) is first matching group in the regsuball. 87 | # 4. Remove all other cookies, identifying them by the fact that they have 88 | # no space after the preceding semi-colon. 89 | # 5. Remove all spaces and semi-colons from the beginning and end of the 90 | # cookie string. 91 | set req.http.Cookie = ";" + req.http.Cookie; 92 | set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";"); 93 | set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=", "; \1="); 94 | set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", ""); 95 | set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", ""); 96 | 97 | if (req.http.Cookie == "") { 98 | # If there are no remaining cookies, remove the cookie header. If there 99 | # aren't any cookie headers, Varnish's default behavior will be to cache 100 | # the page. 101 | unset req.http.Cookie; 102 | } 103 | else { 104 | # If there is any cookies left (a session or NO_CACHE cookie), do not 105 | # cache the page. Pass it on to Apache directly. 106 | return (pass); 107 | } 108 | } 109 | } 110 | 111 | # Set a header to track a cache HITs and MISSes. 112 | sub vcl_deliver { 113 | # Remove ban-lurker friendly custom headers when delivering to client. 114 | unset resp.http.X-Url; 115 | unset resp.http.X-Host; 116 | unset resp.http.Purge-Cache-Tags; 117 | 118 | if (obj.hits > 0) { 119 | set resp.http.X-Varnish-Cache = "HIT"; 120 | } 121 | else { 122 | set resp.http.X-Varnish-Cache = "MISS"; 123 | } 124 | } 125 | 126 | # Instruct Varnish what to do in the case of certain backend responses (beresp). 127 | sub vcl_backend_response { 128 | # Set ban-lurker friendly custom headers. 129 | set beresp.http.X-Url = bereq.url; 130 | set beresp.http.X-Host = bereq.http.host; 131 | 132 | # Cache 404s, 301s, at 500s with a short lifetime to protect the backend. 133 | if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) { 134 | set beresp.ttl = 10m; 135 | } 136 | 137 | # Enable streaming directly to backend for BigPipe responses. 138 | if (beresp.http.Surrogate-Control ~ "BigPipe/1.0") { 139 | set beresp.do_stream = true; 140 | set beresp.ttl = 0s; 141 | } 142 | 143 | # Don't allow static files to set cookies. 144 | # (?i) denotes case insensitive in PCRE (perl compatible regular expressions). 145 | # This list of extensions appears twice, once here and again in vcl_recv so 146 | # make sure you edit both and keep them equal. 147 | if (bereq.url ~ "(?i)\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js)(\?.*)?$") { 148 | unset beresp.http.set-cookie; 149 | } 150 | 151 | # Allow items to remain in cache up to 6 hours past their cache expiration. 152 | set beresp.grace = 6h; 153 | } 154 | -------------------------------------------------------------------------------- /provisioning/templates/nginx-vhost.conf.j2: -------------------------------------------------------------------------------- 1 | {% if item.server_name_redirect is defined %} 2 | server { 3 | listen 80; 4 | server_name {{ item.server_name_redirect }}; 5 | return 301 http://{{ item.server_name.split(' ')[0] }}$request_uri; 6 | } 7 | {% endif %} 8 | 9 | server { 10 | listen {{ item.listen | default("80") }}; 11 | 12 | server_name {{ item.server_name }}; 13 | error_log /var/log/nginx/error.log info; 14 | root {{ item.root }}; 15 | index index.php index.html index.htm; 16 | 17 | {% if item.is_php is defined and item.is_php %} 18 | location / { 19 | # Don't touch PHP for static content. 20 | try_files $uri /index.php?$query_string; 21 | } 22 | 23 | # Don't allow direct access to PHP files in the vendor directory. 24 | location ~ /vendor/.*\.php$ { 25 | deny all; 26 | return 404; 27 | } 28 | 29 | # Use fastcgi for all php files. 30 | location ~ \.php$|^/update.php { 31 | fastcgi_split_path_info ^(.+?\.php)(|/.*)$; 32 | fastcgi_index index.php; 33 | fastcgi_param SCRIPT_FILENAME $request_filename; 34 | fastcgi_intercept_errors on; 35 | fastcgi_read_timeout 120; 36 | include fastcgi_params; 37 | fastcgi_pass {{ php_fpm_listen }}; 38 | } 39 | 40 | location @rewrite { 41 | rewrite ^ /index.php; 42 | } 43 | 44 | location ~ ^/sites/.*/files/styles/ { 45 | try_files $uri @rewrite; 46 | } 47 | 48 | location = /favicon.ico { 49 | log_not_found off; 50 | access_log off; 51 | } 52 | 53 | location = /robots.txt { 54 | allow all; 55 | log_not_found off; 56 | access_log off; 57 | } 58 | 59 | location ~ (^|/)\. { 60 | return 403; 61 | } 62 | 63 | location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { 64 | expires max; 65 | log_not_found off; 66 | } 67 | {% endif %} 68 | 69 | gzip on; 70 | gzip_proxied any; 71 | gzip_static on; 72 | gzip_http_version 1.0; 73 | gzip_disable "MSIE [1-6]\."; 74 | gzip_vary on; 75 | gzip_comp_level 6; 76 | gzip_types 77 | text/plain 78 | text/css 79 | text/xml 80 | text/javascript 81 | application/javascript 82 | application/x-javascript 83 | application/json 84 | application/xml 85 | application/xml+rss 86 | application/xhtml+xml 87 | application/x-font-ttf 88 | application/x-font-opentype 89 | image/svg+xml 90 | image/x-icon; 91 | gzip_buffers 16 8k; 92 | gzip_min_length 512; 93 | } 94 | -------------------------------------------------------------------------------- /provisioning/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | _devtool_docroots: 3 | - "{{ adminer_install_dir }}" 4 | - "{{ pimpmylog_install_dir }}" 5 | - "{{ php_xhprof_html_dir }}" 6 | - "{{ dashboard_install_dir|default('') }}" 7 | 8 | drupalvm_user: "{{ ansible_ssh_user | default(ansible_env.SUDO_USER, true) | default(ansible_env.USER, true) | default(ansible_user_id) }}" 9 | -------------------------------------------------------------------------------- /tests/Dockerfile.centos-7: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | 3 | # Install systemd -- See https://hub.docker.com/_/centos/ 4 | RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs 5 | RUN yum -y update; yum clean all; \ 6 | (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ 7 | rm -f /lib/systemd/system/multi-user.target.wants/*; \ 8 | rm -f /etc/systemd/system/*.wants/*; \ 9 | rm -f /lib/systemd/system/local-fs.target.wants/*; \ 10 | rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ 11 | rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ 12 | rm -f /lib/systemd/system/basic.target.wants/*; \ 13 | rm -f /lib/systemd/system/anaconda.target.wants/*; 14 | 15 | # Install Ansible 16 | RUN yum -y install epel-release 17 | RUN yum -y install git sudo which curl tar unzip xz logrotate initscripts 18 | RUN yum -y install python-setuptools gcc sudo libffi-devel python-devel openssl-devel 19 | RUN yum clean all 20 | RUN easy_install pip 21 | RUN pip install ansible 22 | 23 | # Disable requiretty 24 | RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers 25 | 26 | # Install Ansible inventory file 27 | RUN mkdir -p /etc/ansible 28 | RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts 29 | 30 | VOLUME ["/sys/fs/cgroup"] 31 | CMD ["/usr/sbin/init"] 32 | -------------------------------------------------------------------------------- /tests/Dockerfile.ubuntu-14.04: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | RUN apt-get update 3 | 4 | # Install Ansible 5 | RUN apt-get install -y software-properties-common git 6 | RUN apt-add-repository -y ppa:ansible/ansible 7 | RUN apt-get update 8 | RUN apt-get install -y ansible ufw curl 9 | 10 | COPY initctl_faker . 11 | RUN chmod +x initctl_faker && rm -fr /sbin/initctl && ln -s /initctl_faker /sbin/initctl 12 | 13 | # Install Ansible inventory file 14 | RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts 15 | -------------------------------------------------------------------------------- /tests/centos-7-vars.yml: -------------------------------------------------------------------------------- 1 | mysql_packages: 2 | - mariadb 3 | - mariadb-server 4 | - mariadb-libs 5 | - MySQL-python 6 | - perl-DBD-MySQL 7 | mysql_daemon: mariadb 8 | mysql_log_error: /var/log/mariadb/mariadb.log 9 | mysql_syslog_tag: mariadb 10 | mysql_pid_file: /var/run/mariadb/mariadb.pid 11 | -------------------------------------------------------------------------------- /tests/initctl_faker: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ALIAS_CMD="$(echo ""$0"" | sed -e 's?/sbin/??')" 3 | 4 | case "$ALIAS_CMD" in 5 | start|stop|restart|reload|status) 6 | exec service $1 $ALIAS_CMD 7 | ;; 8 | esac 9 | 10 | case "$1" in 11 | list ) 12 | exec service --status-all 13 | ;; 14 | reload-configuration ) 15 | exec service $2 restart 16 | ;; 17 | start|stop|restart|reload|status) 18 | exec service $2 $1 19 | ;; 20 | \?) 21 | exit 0 22 | ;; 23 | esac 24 | -------------------------------------------------------------------------------- /tests/test-vars.yml: -------------------------------------------------------------------------------- 1 | composer_home_path: "/{{ drupalvm_user }}/.composer" 2 | -------------------------------------------------------------------------------- /tests/ubuntu-14-nginx.yml: -------------------------------------------------------------------------------- 1 | drupalvm_webserver: nginx 2 | --------------------------------------------------------------------------------