Giter VIP home page Giter VIP logo

drupal-vm's Introduction

Drupal VM Logo

DEPRECATION NOTICE: Drupal VM is no longer maintained, and no new releases will be made. See issue #2164 for details. Thank you to all users and maintainers over the past decade!

CI Documentation Status Packagist Docker Automated build irc://irc.freenode.net/drupal-vm

Drupal VM is a VM for Drupal, built with Ansible.

Drupal VM makes building Drupal development environments quick and easy, and introduces developers to the wonderful world of Drupal development on virtual machines or Docker containers (instead of crufty old MAMP/WAMP-based development).

There are two ways you can use Drupal VM:

  1. With Vagrant and VirtualBox.
  2. With Docker.

The rest of this README assumes you're using Vagrant and VirtualBox (this is currently the most flexible and widely-used method of using Drupal VM). If you'd like to use Drupal VM with Docker, please read the Drupal VM Docker documentation.

Drupal VM installs the following on an Ubuntu 18.04 (by default) linux VM:

  • Apache (or Nginx)
  • PHP (configurable version)
  • MySQL (or MariaDB, or PostgreSQL)
  • Drupal 7, 8, or 9
  • Optional:
    • Drupal Console
    • Drush
    • Varnish
    • Apache Solr
    • Elasticsearch
    • Node.js
    • Selenium, for testing your sites via Behat
    • Ruby
    • Memcached
    • Redis
    • SQLite
    • Blackfire, XHProf, or Tideways for profiling your code
    • XDebug, for debugging your code
    • Adminer, for accessing databases directly
    • MailHog, for catching and debugging email

It should take 5-10 minutes to build or rebuild the VM from scratch on a decent broadband connection.

Please read through the rest of this README and the Drupal VM documentation for help getting Drupal VM configured and integrated with your workflow.

Documentation

Full Drupal VM documentation is available at http://docs.drupalvm.com/

Customizing the VM

There are a couple places where you can customize the VM for your needs:

  • config.yml: Override any of the default VM configuration from default.config.yml; customize almost any aspect of any software installed in the VM (more about configuring Drupal VM.
  • drupal.composer.json or drupal.make.yml: Contains configuration for the Drupal core version, modules, and patches that will be downloaded on Drupal's initial installation (you can build using Composer, Drush make, or your own codebase).

If you want to use Drupal 8 on the initial install, do the following:

  1. Set drupal_major_version: 8 inside config.yml.
  2. Set drupal_composer_project_package: "drupal/recommended-project:^8@dev" inside config.yml.

If you want to use Drupal 7 on the initial install, do the following:

  1. Switch to using a Drush Make file.
  2. Update the Drupal version and core inside your drupal.make.yml file.
  3. Set drupal_major_version: 7 inside config.yml.

Quick Start Guide

This Quick Start Guide will help you quickly build a Drupal 9 site on the Drupal VM creating a new Composer project. You can also use Drupal VM with Composer, a Drush Make file, with a Local Drupal codebase, or even a Drupal multisite installation.

If you want to install a Drupal site locally with minimal fuss, just:

  1. Install Vagrant and VirtualBox.
  2. Download or clone this project to your workstation.
  3. cd into this project directory and run vagrant up.

But Drupal VM allows you to build your site exactly how you like, using whatever tools you need, with almost infinite flexibility and customization!

1 - Install Vagrant and VirtualBox

Download and install Vagrant and VirtualBox.

You can also use an alternative provider like Parallels or VMware. (Parallels Desktop 11+ requires the "Pro" or "Business" edition and the Parallels Provider, and VMware requires the paid Vagrant VMware integration plugin).

Notes:

  • For faster provisioning (macOS/Linux only): Install Ansible on your host machine, so Drupal VM can run the provisioning steps locally instead of inside the VM.
  • For stability: Because every version of VirtualBox introduces changes to networking, for the best stability, you should install Vagrant's vbguest plugin: vagrant plugin install vagrant-vbguest.
  • 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 nfs instructions for Linux
  • Versions: Make sure you're running the latest releases of Vagrant, VirtualBox, and Ansible—as of 2020, Drupal VM recommends: Vagrant 2.2.x, VirtualBox 6.1.x, and Ansible 2.9.x

2 - Build the Virtual Machine

  1. Download this project and put it wherever you want.
  2. (Optional) Copy default.config.yml to config.yml and modify it to your liking.
  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).
  4. Open Terminal, cd to this directory (containing the Vagrantfile and this README file).
  5. Type in vagrant up, and let Vagrant do its magic.

Once the process is complete, you will have a Drupal codebase available inside the drupal/ directory of the project.

Note: If there are any errors during the course of running vagrant up, and it drops you back to your command prompt, just run vagrant provision to continue building the VM from where you left off. If there are still errors after doing this a few times, post an issue to this project's issue queue on GitHub with the error.

3 - Access the VM.

Open your browser and access http://drupalvm.test/. The default login for the admin account is admin for both the username and password.

Note: By default Drupal VM is configured to use 192.168.88.88 as its IP, if you're running multiple VM's the auto_network plugin (vagrant plugin install vagrant-auto_network) can help with IP address management if you set vagrant_ip to 0.0.0.0 inside config.yml.

Extra software/utilities

By default, this VM includes the extras listed in the config.yml option installed_extras, for example:

installed_extras:
  - adminer
  # - blackfire
  # - drupalconsole
  - drush
  # - elasticsearch
  # - java
  - mailhog
  [...]

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.

Using Drupal VM

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.

Updating Drupal VM

Drupal VM follows semantic versioning, which means your configuration should continue working (potentially with very minor modifications) throughout a major release cycle. Here is the process to follow when updating Drupal VM between minor releases:

  1. Read through the release notes and add/modify config.yml variables mentioned therein.
  2. Do a diff of your config.yml with the updated default.config.yml (e.g. curl https://raw.githubusercontent.com/geerlingguy/drupal-vm/master/default.config.yml | git diff --no-index config.yml -).
  3. Run vagrant provision to provision the VM, incorporating all the latest changes.

For major version upgrades (e.g. 4.x.x to 5.x.x), it may be simpler to destroy the VM (vagrant destroy) then build a fresh new VM (vagrant up) using the new version of Drupal VM.

System Requirements

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:

  • Intel Core processor with VT-x enabled
  • At least 4 GB RAM (higher is better)
  • An SSD (for greater speed with synced folders)

Other Notes

  • 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.
  • To log into the virtual machine, enter vagrant ssh. You can also get the machine's SSH connection details with vagrant ssh-config.
  • 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).
  • You can change the installed version of Drupal or drush, or any other configuration options, by editing the variables within config.yml.
  • Find out more about local development with Vagrant + VirtualBox + Ansible in this presentation: Local Development Environments - Vagrant, VirtualBox and Ansible.
  • Learn about how Ansible can accelerate your ability to innovate and manage your infrastructure by reading Ansible for DevOps.

Tests

To run basic integration tests using Docker and Molecule:

  1. Install Docker.
  2. Install Molecule: pip3 install ansible molecule[docker]
  3. In this project directory, run: composer run-tests

The project's automated tests are run via GitHub Actions, and the more comprehensive test suite covers multiple Linux distributions and many different Drupal VM use cases and deployment techniques.

License

This project is licensed under the MIT open source license.

About the Author

Jeff Geerling created Drupal VM in 2014 for a more efficient Drupal site and core/contrib development workflow. This project is featured as an example in Ansible for DevOps.

drupal-vm's People

Contributors

danepowell avatar dixhuit avatar entendu avatar frob avatar geerlingguy avatar gobinathm avatar heddn avatar hussainweb avatar iainhouston avatar jimmyko avatar joestewart avatar jonathanjfshaw avatar justinlevi avatar kekkis avatar kevinhowbrook avatar kmbremner avatar mogtofu33 avatar opdavies avatar oxyc avatar petrillek avatar rhuffstedtler avatar rockymountainhigh1943 avatar scottrigby avatar shawnachieve avatar sidneygijzen avatar stephenpurkiss avatar thom8 avatar traviscarden avatar vml-jbartlett avatar weitzman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drupal-vm's Issues

Shouldn't files in d8dev be owned by the vagrant user?

After git clone and vagrant up, I noticed that the owner of the drupal8-dev/* files is root. I found that I was unable to use drush to download a module. Perhaps we should chown to the www-data user and then add vagrant to the www-data group?

sudo chown -R www-data:www-data *
sudo usermod -a -G `whoami` www-data
vagrant@precise64:/var/www/drupal-8.x-dev$ ll
total 168
drwxr-xr-x  8 root root  4096 Jul  5 17:19 ./
drwxr-xr-x  3 root root  4096 Jul  5 17:18 ../
-rw-r--r--  1 root root  1559 Jul  5 17:19 composer.json
-rw-r--r--  1 root root 84227 Jul  5 17:19 composer.lock
drwxr-xr-x 13 root root  4096 Jul  5 17:19 core/
-rw-r--r--  1 root root   317 Jul  5 17:19 .editorconfig
-rw-r--r--  1 root root   135 Jul  5 17:19 .eslintignore
-rw-r--r--  1 root root   660 Jul  5 17:19 .eslintrc
-rw-r--r--  1 root root  1086 Jul  5 17:19 example.gitignore
drwxr-xr-x  8 root root  4096 Jul  5 17:19 .git/
-rw-r--r--  1 root root  3234 Jul  5 17:19 .gitattributes
-rw-r--r--  1 root root  6648 Jul  5 17:19 .htaccess
-rw-r--r--  1 root root  1298 Jul  5 17:19 index.php
drwxr-xr-x  2 root root  4096 Jul  5 17:19 modules/
drwxr-xr-x  2 root root  4096 Jul  5 17:19 profiles/
-rw-r--r--  1 root root  4987 Jul  5 17:19 README.txt
-rw-r--r--  1 root root  1281 Jul  5 17:19 robots.txt
drwxr-xr-x  3 root root  4096 Jul  5 17:19 sites/
drwxr-xr-x  2 root root  4096 Jul  5 17:19 themes/
-rw-r--r--  1 root root  3990 Jul  5 17:19 web.config

Error when installing apache on the guest machine

This morning I saw a few things changed so I pulled the latest changes, destroyed the last VM I've created and did another vagrant up. Everything is working ok until this:

TASK: [geerlingguy.apache | Ensure Apache is installed.] ********************** 
failed: [drupaldev] => (item=apache2,apache2-mpm-prefork,apache2-utils) => {"failed": true, "item": "apache2,apache2-mpm-prefork,apache2-utils"}
stderr: dpkg: error processing archive /var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~trusty+5_amd64.deb (--unpack):
 error setting ownership of `/var/www/html.dpkg-new': Operation not permitted
Errors were encountered while processing:
 /var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~trusty+5_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

stdout: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  apache2-bin apache2-data libaprutil1-dbd-sqlite3 libaprutil1-ldap
  liblua5.1-0
Suggested packages:
  www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-mpm-prefork apache2-utils
  libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0
0 upgraded, 8 newly installed, 0 to remove and 125 not upgraded.
Need to get 1,526 kB of archives.
After this operation, 5,661 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php5/ubuntu/ trusty/main libaprutil1-dbd-sqlite3 amd64 1.5.3-2+deb.sury.org~trusty+1 [16.2 kB]
Get:2 http://ppa.launchpad.net/ondrej/php5/ubuntu/ trusty/main libaprutil1-ldap amd64 1.5.3-2+deb.sury.org~trusty+1 [14.3 kB]
Get:3 http://ppa.launchpad.net/ondrej/php5/ubuntu/ trusty/main apache2-bin amd64 2.4.12-1+deb.sury.org~trusty+5 [949 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main liblua5.1-0 amd64 5.1.5-5ubuntu0.1 [99.9 kB]
Get:5 http://ppa.launchpad.net/ondrej/php5/ubuntu/ trusty/main apache2-utils amd64 2.4.12-1+deb.sury.org~trusty+5 [137 kB]
Get:6 http://ppa.launchpad.net/ondrej/php5/ubuntu/ trusty/main apache2-data all 2.4.12-1+deb.sury.org~trusty+5 [162 kB]
Get:7 http://ppa.launchpad.net/ondrej/php5/ubuntu/ trusty/main apache2 amd64 2.4.12-1+deb.sury.org~trusty+5 [146 kB]
Get:8 http://ppa.launchpad.net/ondrej/php5/ubuntu/ trusty/main apache2-mpm-prefork amd64 2.4.12-1+deb.sury.org~trusty+5 [1,430 B]
Fetched 1,526 kB in 1s (767 kB/s)
Selecting previously unselected package liblua5.1-0:amd64.
(Reading database ... 60889 files and directories currently installed.)
Preparing to unpack .../liblua5.1-0_5.1.5-5ubuntu0.1_amd64.deb ...
Unpacking liblua5.1-0:amd64 (5.1.5-5ubuntu0.1) ...
Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
Preparing to unpack .../libaprutil1-dbd-sqlite3_1.5.3-2+deb.sury.org~trusty+1_amd64.deb ...
Unpacking libaprutil1-dbd-sqlite3:amd64 (1.5.3-2+deb.sury.org~trusty+1) ...
Selecting previously unselected package libaprutil1-ldap:amd64.
Preparing to unpack .../libaprutil1-ldap_1.5.3-2+deb.sury.org~trusty+1_amd64.deb ...
Unpacking libaprutil1-ldap:amd64 (1.5.3-2+deb.sury.org~trusty+1) ...
Selecting previously unselected package apache2-bin.
Preparing to unpack .../apache2-bin_2.4.12-1+deb.sury.org~trusty+5_amd64.deb ...
Unpacking apache2-bin (2.4.12-1+deb.sury.org~trusty+5) ...
Selecting previously unselected package apache2-utils.
Preparing to unpack .../apache2-utils_2.4.12-1+deb.sury.org~trusty+5_amd64.deb ...
Unpacking apache2-utils (2.4.12-1+deb.sury.org~trusty+5) ...
Selecting previously unselected package apache2-data.
Preparing to unpack .../apache2-data_2.4.12-1+deb.sury.org~trusty+5_all.deb ...
Unpacking apache2-data (2.4.12-1+deb.sury.org~trusty+5) ...
Selecting previously unselected package apache2.
Preparing to unpack .../apache2_2.4.12-1+deb.sury.org~trusty+5_amd64.deb ...
Unpacking apache2 (2.4.12-1+deb.sury.org~trusty+5) ...
Selecting previously unselected package apache2-mpm-prefork.
Preparing to unpack .../apache2-mpm-prefork_2.4.12-1+deb.sury.org~trusty+5_amd64.deb ...
Unpacking apache2-mpm-prefork (2.4.12-1+deb.sury.org~trusty+5) ...
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for ureadahead (0.100.0-16) ...

msg: 'apt-get install 'apache2' 'apache2-mpm-prefork' 'apache2-utils'' failed: dpkg: error processing archive /var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~trusty+5_amd64.deb (--unpack):
 error setting ownership of `/var/www/html.dpkg-new': Operation not permitted
Errors were encountered while processing:
 /var/cache/apt/archives/apache2_2.4.12-1+deb.sury.org~trusty+5_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/rnegrean/playbook.retry

drupaldev                  : ok=16   changed=8    unreachable=0    failed=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

How do we specify the install of 6, 7, or 8?

How do we specify the install of 6, 7, or 8? A previous version had a something in vars.yaml. I'm not seeing this in this current rendition. Thanks again for releasing this!

vagrant up error

vm:

  • The host path of the shared folder is missing: ~/Sites/drupal

Add VMWare Fusion support

I'm working on adding VMWare Fusion support, as I've finally bought the licenses for everything, and want to see what kind of differences I can get in terms of Drupal performance in local VMs with VMWare Fusion vs. VirtualBox.

Should drupal.make.yml be a configuration file as well?

I notice that to get Drupal 7 or 6, drupal.make.yml has to be changed, but it's not in .gitignore, hence the repo gets dirty and the config can't be as easily updated when there are changes.

Should this be done up like config.yml?

I'm using D8, just noticed this and thought to ask.

Get username from config variable

There is a hardcode username of vagrant in some of the `provisioning/tasks/' files. It would be nice to set a variable in the config and then use that instead, in case someone wants to set a different username.

https://github.com/geerlingguy/drupal-dev-vm/blob/master/provisioning/tasks/www.yml#L9
https://github.com/geerlingguy/drupal-dev-vm/blob/master/provisioning/tasks/www.yml#L15
https://github.com/geerlingguy/drupal-dev-vm/blob/master/provisioning/tasks/drupal.yml#L59

Document how to use drupal-vm with multisite, multiple docroots, etc.

Now that #33 has made the drupal-vm a lot more flexible (no longer does it always install a site from a makefile, you can use different kinds of Drupal sites (like sites where the entire site is in a local directory on the host, and the user installs a database), and as many as you want at the same time.

I'd like to document how to do some of the most common setups:

  1. Site with docroot shared from host machine (configure vagrant_synced_folders and apache_vhosts, and set build_from_makefile to false).
  2. Site that uses multisite for multiple domains pointing to the same docroot (configure vagrant_synced_folders, add multiple apache_vhosts with the same documentroot, and set build_from_makefile to false).
  3. Site that uses a Drush make file (configure vagrant_synced_folders and set build_from_makefile to true).

I really think that, short of using an actual playbook that builds your prod server (or entire infrastructure) locally, this VM is now capable of doing most of what's necessary for reliable local Drupal development. I might also need to add easier options for PHP version switching (like in acquia-cloud-vm) and add the ability to switch Ubuntu versions (should be simple enough to toggle 12.04 and 14.04 (current default)... maybe even allow switching to CentOS 6/7!).

Creating the share folder on the host if it does not exist

I think it will be a good idea to have a create key for share folder like this in config.yml

vagrant_synced_folders:
  # The first synced folder will be used for the default Drupal installation, if
  # build_from_makefile is 'true'.
  - local_path: ~/Sites/drupalvm
        destination: /var/www
        id: drupal
        type: nfs
        create: TRUE

and in Vagrantfile to do it like this

 for synced_folder in vconfig['vagrant_synced_folders'];
        config.vm.synced_folder synced_folder['local_path'], synced_folder['destination'],
            type: synced_folder['type'],
            rsync__auto: "true",
            rsync__exclude: synced_folder['excluded_paths'],
            rsync__args: ["--verbose", "--archive", "--delete", "-z", "--chmod=ugo=rwX"],
            id: synced_folder['id'],
            create: synced_folder['create']
  end

Bash command to clone and run

In my alias.sh script (that auto-loads through my bash profile), I've added a function called newd clones this repo, uses sed to change configuration to Drupal 7 if desired, renames the VM to something other than drupaltest.dev, and starts vagrant up. Nothing to ground breaking but I thought I would share it since I use this all of the time to spin up new sites. I also don't need to remember the exact repo name.

Such as $ newd 7 test-fieldformatter or $ newd 8 drupal8test

https://gist.github.com/rgoodie/9966f30b404a4daa59e1

How to SSH and Drush

Hi, thank you for this project. Really excited to get it all running. Being new to VirtualBox/Vagrant etc. I'm having a hard time figuring out how it's supposed to work.

I've got a Sites/drupalvm/drupal (8) installation which appears on 192.168.88.88 and I've succesfully connected to the DB using Sequel Pro as per your instructions.

How do you use Drush? I assume I have to ssh [email protected] locally and then Drush will be available? If so, what's the default password?

Is there a default admin user I can log in to the Drupal installation with?

Use Ubuntu 14.04 instead of 12.04

The world has moved on... although many hosting providers and guides still focus on 12.04, I'd like this dev VM to be as efficient and simple as possible, and Ubuntu 14.04 has some niceties built in that we won't need to have upgraded, like PHP 5.4 by default, Apache 2.4, etc.

Plus, since almost all my roles are already working on 14.04, this shouldn't be too difficult. Just need to test and fix any roles that are lagging.

Provision error

failed: [drupaldev] => {"changed": true, "cmd": ["drush", "make", "-y", "/vagrant/drupal.make.yml", "/var/www/drupal"], "delta": "0:00:32.571113", "end": "2015-01-10 21:24:00.839312", "rc": 1, "start": "2015-01-10 21:23:28.268199"}
stderr: Beginning to build /vagrant/drupal.make.yml. [ok]
drupal-8.0.x-dev downloaded. [ok]
File devel-8.x-1.x-dev.tar.gz_date=1420592880 is corrupt (wrong md5 [error]
checksum).

FATAL: all hosts have already failed -- aborting
drupaldev : ok=88 changed=2 unreachable=0 failed=1

Add XDebug

geerlingguy.php-xdebug role... add it!

Message: (./config.yml): did not find expected key while parsing a block mapping at line 3 column 1

Hello,

I'm getting the following error when I run vagrant up:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: /Users/alastair/dev/experimental/drupal/ajax/Vagrantfile
Message: (./config.yml): did not find expected key while parsing a block mapping at line 3 column 1

A copy of my config.yml is as follows:


---
# Vagrant hostname and IP configuration.
vagrant_hostname: ajax.vm
vagrant_ip: 192.168.34.10
vagrant_user: vagrant

# A list of synced folders, with the keys 'local_path', 'destination', 'id', and
# a 'type' of [nfs|rsync|smb] (leave empty for slow native shares).
vagrant_synced_folders:
  # The first synced folder will be used for the default Drupal installation, if
  # build_from_makefile is 'true'.
  - local_path: /Users/alastair/dev/experimental/drupal/ajax
    destination: /var/www
    id: drupal
    type: nfs

# Memory and CPU to use for this VM.
vagrant_memory: 1024
vagrant_cpus: 2

# Set this to false if you are using a different site deployment strategy and
# would like to configure 'vagrant_synced_folders' and 'apache_vhosts' manually.
build_from_makefile: true
drush_makefile_path: /vagrant/drupal.make.yml

# Settings for building a Drupal site from a makefile (if 'build_from_makefile'
# is 'true').
drupal_major_version: 7
drupal_core_path: "/var/www/drupal"
drupal_domain: "ajax.vm
drupal_site_name: "AJAX Dev"
drupal_install_profile: standard
drupal_enable_modules: [ 'devel' ]
drupal_mysql_user: admin
drupal_mysql_password: password

# Apache VirtualHosts. Add one for each site you are running inside the VM. For
# multisite deployments, you can point multiple servernames at one documentroot.
apache_vhosts:
  - {servername: "{{ drupal_domain }}", documentroot: "{{ drupal_core_path }}"}
  - {servername: "local.xhprof.com", documentroot: "/usr/share/php/xhprof_html"}

# MySQL Databases and users. If build_from_makefile is true, first database will
# be used for the makefile-built site.
mysql_databases:
  - name: drupal
    encoding: utf8
    collation: utf8_general_ci

mysql_users:
  - name: drupal
    host: "%"
    password: drupal
    priv: "drupal.*:ALL"

# Comment out any extra utilities you don't want to install.
installed_extras:
  - mailhog
  - memcached
  - phpmyadmin
  - xdebug
  - xhprof

# You can configure almost anything else on the server in the rest of this file.
mysql_root_password: root
drush_version: master

firewall_allowed_tcp_ports:
  - "22"
  - "25"
  - "80"
  - "443"
  - "8025"
  - "8080"
  - "8443"

php_memory_limit: "256M"
php_display_errors: "On"
php_realpath_cache_size: "1024K"
php_sendmail_path: "/usr/sbin/ssmtp -t"

# Disable main XDebug components unless needed.
php_xdebug_coverage_enable: 0
php_xdebug_default_enable: 0

Any ideas?

Thanks!

Multisite setup?

Hi. I've got it working great so far and I'm wondering what would be the recommended practice for implementing a multi-site setup with separate databases in this scenario? Would the subdirectory paths be defined in main.yml and then edit /etc/hosts? I'm using Drupal 7.

Install instructions flow

Thanks, this is great!

I was following the install instructions - the following line is listed before downloading this repository which contains the requirements.txt:

"1.4 Install Ansible Galaxy roles required for this VM: $ ansible-galaxy install -r requirements.txt"

I'm guessing it needs to be slotted between 2.2 and 2.3 - also had to sudo it so wasn't sure enough how to change this to submit a pull request.

Can't find role php-pecl

This morning I re-grabbed this (via git reset --hard && git pull). Upon launching a provision (vagrant up && vagrant provision) I got the following error.

~/vagrant/drupal-dev-vm$ vagrant provision
[default] Running provisioner: ansible...
ERROR: cannot find role in /home/r/vagrant/drupal-dev-vm/provisioning/roles/geerlingguy.php-pecl or /home/r/vagrant/drupal-dev-vm/provisioning/geerlingguy.php-pecl or /etc/ansible/roles/geerlingguy.php-pecl
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

The Drupal make file was left at default 8 settings (untouched)

Rename project to drupal-vm

I just registered the domain drupalvm.com, and am going to submit this VM into the fray as a decent option for local Drupal development, once I finish a couple other tweaks. So part of this process is renaming this project to 'drupal-vm'.

Anyone with an existing repo will need to update his or her remote, but that's a simple process like:

git remote rm origin
git remote add origin [email protected]:geerlingguy/drupal-vm.git

In an attempt to install Drupal 8 by changing the make file, I received an error

After a git clone of this repo, I altered the drupal.make file as follows:

core = 8.x
api = 2

; Drupal core
projects[drupal][version] = 8.x

; Contrib modules
projects[] = devel

After which, I ran vagrant up and received this error

TASK: [Install modules with drush.] ******************************************* 
failed: [default] => {"changed": true, "cmd": ["drush", "en", "-y", "devel"], "delta": "0:00:03.875489", "end": "2014-08-06 14:25:16.066690", "item": "", "rc": 255, "start": "2014-08-06 14:25:12.191201"}
stderr: PHP Fatal error:  Declaration of Drupal\devel\Form\SettingsForm::buildForm() must be compatible with Drupal\Core\Form\FormInterface::buildForm(array $form, array &$form_state) in /var/www/drupal/modules/devel/src/Form/SettingsForm.php on line 17
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Declaration of Drupal\devel\Form\SettingsForm::buildForm()
must be compatible with
Drupal\Core\Form\FormInterface::buildForm(array $form, array
&$form_state) in
/var/www/drupal/modules/devel/src/Form/SettingsForm.php, line 17
stdout: The following extensions will be enabled: devel
Do you really want to continue? (y/n): y

FATAL: all hosts have already failed -- aborting

New multisite strategy

Currently if you want to install multiple Drupal sites inside the VM, you have to edit a couple things, e.g.:

vagrant_synced_folders:
  - local_path: ~/Sites/drupal
    destination: /drupal
    excluded_paths: [".git/"]
    id: drupal
    type: rsync
apache_vhosts:
  - {servername: "{{ drupal_domain }}", documentroot: "{{ drupal_core_path }}"}

...also, the VM installs the site defined in drupal.make.yml by default, with no option to disable. It would be much more flexible and simple if there was a way to define multiple Drupal sites, and use a deployment_strategy per site (or something like that) to deploy it inside the VM.

That way, I could maybe have one site located at ~/Sites/my-site which has a .make.yml file to install, another site at ~/Sites/company-site which has a full Drupal codebase and would just need to be synced inside the VM...

I'm trying to think through the best syntax for this that would be the least complex, most flexible, and also not a pain to maintain inside Ansible and Vagrant (e.g. dynamically creating the apache_vhosts and vagrant_synced_folders variables).

Maybe something like the following:

drupal_sites:

  - servername: drupaltest.dev
    local_path: ~/Sites/my-site
    dest_path: /var/www/my-site
    deployment_strategy: drush_make
    makefile: drupal.make.yml
    sync_method: rsync

  - servername: drupaltest.dev
    local_path: ~/Sites/company-site
    dest_path: /var/www/company-site
    deployment_strategy: full_repository
    sync_method: nfs

Another potential advantage here is that we might be able to fabricate a Drush alias file for the entire VM from within the Ansible playbook, and either place it in the right place locally/automatically, or stick it inside the VM somewhere and let the user grab it if so desired.

I'd like the default configuration/example still to just install the latest version of Drupal core with a makefile (since that's my preferred method of site development/deployment these days anyways), but if it were this easy to have multiple sites inside one VM, I would be able to use the drupal-dev-vm for almost all my Drupal sites (at least all the ones that don't rely on exotic configurations or specific versions of software...).

APC is not installed/setup correctly

It seems I've forgotten to get this working. D'oh!

For now, if you need it to be installed, after all provisioning is complete, run the following two commands:

$ sudo apt-get install -y php-apc

Additionally, maybe look into automatically switching to opcache settings if on PHP >= 5.5. Though that might be an issue to be opened over in the geerlingguy.php role.

Don't install Apache Solr by default

Solr and Java add about 200 MB to the baseline install of Drupal VM, and since it's not as widely required for Drupal projects as many other applications, I'm going to leave it commented in the default list of installed_extras.

Use a makefile to build the site, don't use geerlingguy.drupal

Though my Ansible role for Drupal is flexible(ish) enough to do most things, I think this dev vm would benefit from being built with a Drush makefile, and more variables should be utilized so someone could easily pop in (via a fork, or maybe via included vars) whatever modules/configuration/patches, etc. someone would need.

In my case, I often want to install devel, maybe solr, maybe some other handy modules, and if I had a makefile with a few simple variables I could define in vars.yml, I could have the VM set up precisely how I'd like.

Initial file ownership

(This was also reported in #7 but wanted to separate it out for clarity)

After modifying the drupal.make to get d8 and executing vagrant provision, I got the white screen of death. A bit of exploration showed that all files in /var/www/drupal were owned by the vagrant user. I changed ownership (sudo chown www-data -R *) and everything worked after that.

Add the ability to specify the install profile

First of all, thank you so much for this package. It is saving me so much in time and headaches that I can only express my gratitude in beers.

That said, it would be a huge plus if config.yml contained a variable allowing me to change the install profile that gets deployed when Drupal is installed. I'm pretty sure drush si accepts such an option, so it should be fairly trivial to add...

Drupal 6 + Drush 6 support

Hi, everything seems to work fine with D8 and D7, but I run into errors when installing D6.

It seems that at some point the /var/www/drupal directory is not being created.

This is the last part of the Ansible output:

TASK: [Remove default virtualhost file.] ************************************** 
changed: [drupaldev]

TASK: [Check if Drupal is already set up.] ************************************ 
ok: [drupaldev]

TASK: [Generate Drupal site with drush makefile.] ***************************** 
changed: [drupaldev]

TASK: [Install Drupal (standard profile) with drush.] ************************* 
failed: [drupaldev] => {"failed": true, "rc": 258}
msg: cannot change to directory '/var/www/drupal': path does not exist

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/mikechelen/playbook.retry

drupaldev                  : ok=121  changed=56   unreachable=0    failed=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

These are the relevant lines from:
config.yml:

drupal_major_version: 6
drush_version: master

Also tried drush_version: 6.x

drupal.make.yml:

core: 6.x

projects:

  drupal:
    type: core
    version: 6.x

  devel: 1.x

Also tried with core: 6.34 and version: 6.34

Make installation of extra utilities optional

Right now, the default installation configures XHProf, MailHog, XDebug, etc.

Additionally, I'd like to add phpmyadmin support OOTB and allow users who want it to be able to toggle it on or off.

But I hate kludging up my dev environment with tools that I don't need 95% of the time. It wastes RAM, CPU cycles, and time spent downloading/configuring the tools. Therefore I'd like to add a set of vars in config.yml like:

installed_extras:
  - xhprof
  - xdebug
  - phpmyadmin
  - mailhog
  - etc.

Alternatively, I could use a variable per-utility, like install_xhprof: false, but the above approach might be simpler...

Since these things are already installed via roles, I can just add when conditionals to each role and only install the roles if called for. All the roles would still need to be in requirements.txt.

Error provisioning: cannot file role geerlingguy.firewall

I'm getting the following error:

ERROR: cannot find role in /Users/alastair/dev/experimental/drupal/ajax/provisioning/roles/geerlingguy.firewall or /Users/alastair/dev/experimental/drupal/ajax/provisioning/geerlingguy.firewall or /usr/local/etc/ansible/roles/geerlingguy.firewall
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

Any ideas?

Thanks!

Add XHProf

I have a shiny new geerlingguy.xhprof role. I would like to add it to this VM (shiny callback graphs and profiling!).

Make drush makefile name/path configurable

Currently the drush make file that's used to build the Drupal site if build_from_makefile is set to true is hardcoded as /vagrant/drupal.make.yml, so it must exist in the drupal-vm project folder's root directory and be named, exactly, drupal.make.yml.

I think I could just add a new variable, right after build_from_makefile, to set the path to the make file. For the default, it can still be /vagrant/drupal.make.yml, so the quick start guide is still correct.

Set up Drupal in a synced folder for easier development

I have a little problem and can't seem to find a solution for it: I want the project to be in the synch folder.
I've tried to set /var/www/drupal in the VM to be the synch folder instead of /drupal, but when the VM boots, the folder is synched with the local one which is empty, so no more drupal installation.
Is there any way to achieve this ?

Outdated Ansible version sometimes causes Drush install failure on Windows

Hi Jeff, I've been using drupal-vm on Linux all week with great results. Today is the my first test with drupal-vm on Windows. So far I've not gotten it to work. Here's the error I'm getting:

==> drupaldev: TASK: [geerlingguy.drush | Install Drush dependencies with Composer.] ********* 
==> drupaldev: failed: [localhost] => {"failed": true, "rc": 258}                              
==> drupaldev: msg: cannot change to directory '/usr/local/share/drush': path does not exist   
==> drupaldev:                                                                                 
==> drupaldev: FATAL: all hosts have already failed -- aborting                                
==> drupaldev:                                                                                 
==> drupaldev: PLAY RECAP ******************************************************************** 
==> drupaldev:            to retry, use: --limit @/root/playbook.retry                         
==> drupaldev:                                                                                 
==> drupaldev: localhost                  : ok=67   changed=29                                 
==> drupaldev:  unreachable=0    failed=1                                                      
The SSH command responded with a non-zero exit status. Vagrant                                 
assumes that this means the command failed. The output for this command                        
should be in the log above. Please read the output to determine what                           
went wrong.                                                                                    

Let me know what I can do to troubleshoot further. I did change to Drupal 7 in drupal.make.yml version: "7.0.x".

Windows 7 x64
Git bash shell

Thanks!
--Tony (@drupleg)

git clone every time vagrant up?

am new to ansible

can you tell me, does "vagrant reload" reinstall?

does
vagrant halt
vagrant up

new site?

how do you do development with an existing code base? I am trying to change the apache vhost to point to a shared folder on host with existing code

but how do I manage db and code and files if ansible reinstalls every vagrant up?

please tell me I am wrong

Error while building D7 with custom modules

I got the following trying to provision a D7 instance today

TASK: [Symlink custom modules directory into place.] **************************
failed: [default] => {"failed": true, "item": "", "path": "/var/www/drupal/modules/custom", "state": "absent"}
msg: Error while linking: [Errno 2] No such file or directory

drupal.make file was as follows:

$ cat drupal.make
; Basic Drush Make file for Drupal. Be sure to update the drupal_major_version
; variable inside provisioning/vars/main.yml if you change the major version in
; this file.

; Drupal core (major version, e.g. 6.x, 7.x, 8.x).
;core = 8.x
core=7.x

; Drush Make API version.
api = 2

; Drupal core (e.g. 6.29, 7.x, 7.30, 8.0.x, etc.)
;projects[drupal][version] = 8.0.x
projects[drupal][version] = 7.x
; Contrib modules
projects[] = devel

vars/main.yaml was unchanged as follows


---
mysql_root_password: ''
drush_version: master

# Major release of drupal in use (6, 7, 8, etc.). Be sure to update the core
# version inside the drupal.make file if you change the major version here.
drupal_major_version: 7

# The path where Drupal will be downloaded and installed.
drupal_core_path: "/var/www/drupal"

drupal_domain: "drupaltest.dev"
drupal_site_name: "Drupal Test Site"

drupal_mysql_user: root
drupal_mysql_password: ''
drupal_mysql_database: drupal

apache_vhosts:
  - {servername: "{{ drupal_domain }}", documentroot: "{{ drupal_core_path }}"}

Troubles installing: Symlinkin' and Folder makin'

At first I ran into "can't find box guygeerling/ubuntu1204". So I switched out that for another 12.04 box I have.

Things went a bit more smoothly then I hit a point where /var/www/drupal couldn't be created. I ssh'ed in and manually creating it. Giving it temporarily full permissions (777).

TASK: [Generate Drupal site with drush makefile.] ***************************** 
failed: [default] => {"changed": true, "cmd": ["drush", "make", "-y", "/vagrant/drupal.make", "/var/www/drupal"], "delta": "0:00:00.838308", "end": "2014-11-13 15:34:08.919124", "item": "", "rc": 1, "start": "2014-11-13 15:34:08.080816"}
stderr: Beginning to build /vagrant/drupal.make.                             [ok]
No core project specified.                                           [error]

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/r/playbook.retry

default                    : ok=78   changed=36   unreachable=0    failed=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
r@s:~/vagrant/drupal-dev-vm$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
New release '14.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Welcome to your Vagrant-built virtual machine.
Last login: Thu Nov 13 15:34:08 2014 from 10.0.2.2
vagrant@precise64:~$ sudo mkdir /var/www/drupal
vagrant@precise64:~$ sudo chmod 777 /var/www/drupal -R
vagrant@precise64:~$ exit

Then I seemed to have hit another stop point when it was trying to create /var/www/drupal/sites/all/modules/custom.

TASK: [Symlink custom modules directory into place.] ************************** 
failed: [default] => {"failed": true, "item": "", "path": "/var/www/drupal/sites/all/modules/custom", "state": "absent"}
msg: Error while linking: [Errno 2] No such file or directory

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/r/playbook.retry

default                    : ok=73   changed=1    unreachable=0    failed=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

Again, I manually created this, exited back out, and reran vagrant provision. Then this happened.

TASK: [Symlink custom modules directory into place.] ************************** 
failed: [default] => {"failed": true, "gid": 999, "group": "admin", "item": "", "mode": "0775", "owner": "vagrant", "path": "/var/www/drupal/sites/all/modules/custom", "size": 4096, "state": "directory", "uid": 1000}
msg: refusing to convert between directory and link for /vagrant/custom_modules

FATAL: all hosts have already failed -- aborting

GIT DIFF

$ git diff master..changes
diff --git a/Vagrantfile b/Vagrantfile
index a71fc37..6ce03ea 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -3,7 +3,7 @@
 VAGRANTFILE_API_VERSION = "2"

 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
-  config.vm.box = "geerlingguy/ubuntu1204"
+  config.vm.box = "ubuntu-precise12042-x64-vbox43"
   config.vm.network :private_network, ip: "192.168.88.88"

   # Share a folder using a basic VirtualBox shared folder.
diff --git a/drupal.make b/drupal.make
index 97b4280..7f0d64e 100644
--- a/drupal.make
+++ b/drupal.make
@@ -3,7 +3,7 @@
 ; this file.

 ; Drupal core (major version, e.g. 6.x, 7.x, 8.x).
-core = 8.x
+core = 7.x

 ; Drush Make API version.
 api = 2
@@ -11,14 +11,18 @@ api = 2
 ; Method 1 - Install Drupal core version directly (e.g. 6.29, 7.x, 7.30, 8.0.x).
 ; Note: This method doesn't currently work with semantic versioning with Drush.
 ; (see: https://github.com/drush-ops/drush/issues/896).
-; projects[drupal][version] = 8.0.x
+; projects[drupal][version] = 7.x

 ; Alternatively, use git.
-projects[drupal][download][type] = git
-projects[drupal][download][url] = http://git.drupal.org/project/drupal.git
-projects[drupal][download][branch] = 8.0.x
+;projects[drupal][download][type] = git
+;projects[drupal][download][url] = http://git.drupal.org/project/drupal.git
+;projects[drupal][download][branch] = 8.0.x
 ; projects[drupal][download][tag] = 8.0.0-beta2
 ; projects[drupal][download][revision] = xyz

 ; Contrib modules
 projects[] = devel
+projects[] = coffee
+projects[] = module_filter
+projects[] = views
+projects[] = view_ui
diff --git a/provisioning/vars/main.yml b/provisioning/vars/main.yml
index 7cd0bd2..477fee1 100644
--- a/provisioning/vars/main.yml
+++ b/provisioning/vars/main.yml
@@ -4,7 +4,7 @@ drush_version: master

 # Major release of drupal in use (6, 7, 8, etc.). Be sure to update the core
 # version inside the drupal.make file if you change the major version here.
-drupal_major_version: 8
+drupal_major_version: 7

Memcached support

By default memcached support is enabled in the config.yml, but to make this work I had to add the following lines to the requirements.txt:

geerlingguy.memcached
geerlingguy.php-memcached

Is this correct? or did i miss something else?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.