I’ve been on a bit of a local development kick lately. I tested out @10up’s Docker setup. I’ve been using MAMP Pro on my new laptop. And now I dug back into Vagrant.
In digging back into Vagrant I found that my old Vagrant setup has become outdated with the release of Varying Vagrant Vagrants1 2.0.0. At least the portion on automating WordPress site creation with Variable VVV2 as it doesn’t yet support VVV 2.0.0.
But that’s in part because VVV made it easier to automate this yourself using a vvv-custom.yml configuration file. And you don’t even have to know what the hell a .yml file is to do it!
All your VVV-Base are belong to us.
The new .yml config makes it easy to create presets for sites you’ll be developing on Vagrant. And the inclusion of a repo section means plenty of people have already put in the hard work to make nice auto setups we can take advantage of.
I like VVV-Base for it’s option for adding plugins and themes to your setup process. As well as deleting existing themes and plugins, multisite setup, db prefixing, and more. All from the comfort of your text-editor.
All it takes is this added to a vvv-custom.yml file.
sites: # The following site configuration will create an environment for a local WordPress site named 'example-site' that can be accessed in your browser at example.local # To add another site copy everything below this point and edit it to your hearts content. See more options avaialable at [GitHub - JPry/vvv-base: Base repository for new VVV sites](https://github.com/JPry/vvv-base) example-site: repo: https://github.com/JPry/vvv-base.git hosts: - example.local custom: admin_user: admin admin_password: password admin_email: [email protected] title: An Awesome Example Site db_prefix: ex_ multisite: false xipio: true version: latest locale: en_US plugins: - jetpack - { plugin: "https://github.com/afragen/github-updater/archive/6.3.1.zip", force: true, activate: true } themes: - the-authority delete_default_plugins: true delete_default_themes: true
Setting up a custom .yml file
If you’ve installed VVV already you should have a vagrant-local
folder somewhere on your machine3. Within this directory you’ll see a vvv-config.yml
file. Duplicate that file and rename it to vvv-custom.yml
.
Take a second to read through the comments in the file before you clean it out and drop in the block of code above. You’ll get a good explanation of how the configuration works there.
Once you have your file saved you’ll need to run a provision on your Vagrant. The fastest way to do this is to run the following in your command line vagrant provision --provision-with site-example-site
. Simply replace example-site
with any additional site names you add in the future and you’re good to go.
If you ever want to skip a site to keep your Vagrant provisioning running quick you can drop in the skip_provisioning
VVV parameter to true
. Your site configuration and files will still exist, Vagrant just won’t bother provisioning the site when you run vagrant up
. This can greatly reduce the number of sites your vagrant needs to setup when you start. And slow start is the main reason I hadn’t gotten around to getting VVV set up on my new laptop.
Conclusion
That’s it. Get out there and start building awesome automated development environments with Vagrant!
- Henceforth referred to as VVV
- Separate from VVV but built on it.
- Or whichever custom directory you cloned the repo into