Using Salt Stack and Vagrant for Drupal Development
Package the Updated Box
Now that the guest additions are updated, you should repackage a new box so the guest additions match each time you turn on this Vagrant box. This keeps you from needing to update them every time. As long as you don't change the version of VirtualBox that you are using, you won't need to update your guest additions. If you do, you'll need to update them again.
vagrant package command, export your new
This will shut down your machine and export a
package.box file in the current directory.
Rename this to something more descriptive, like myprecise64.box.
Now add this new box to Vagrant:
vagrant box add myprecise64 myprecise64.box
The names you give your boxes are arbitrary and entirely up to you. Feel free to use a description that makes sense to you.
You're done with the original box now, so destroy it with
destroy. You can remove it entirely from Vagrant with
vagrant box remove precise64.
Add your new myprecise64 box, or whatever you happened to call it,
like you did previously with the base box you downloaded with
Make sure to change the name in your Vagrantfile to match the new box,
and test it with
Congratulations! You now have an updated Ubuntu 12.04 VirtualBox suitable for Salt Stack and Salty-Vagrant automation.
Install the Vagrant Salty-Vagrant Gem
The final piece of software you'll need to install is the Salty-Vagrant gem. It allows the automatic installation of Salt Stack on your guest virtual machines and uses Salt Stack to initiate your configuration and installation of software on them as well.
Back on your host machine (that is, the one that is not your
use the Vagrant gem command
vagrant gem install
install the Salty-Vagrant gem.
Add a Salty-Vagrant-Specific Vagrantfile
Now you need to add a slightly customized Vagrantfile to configure some Salt-specific parameters, share your state tree and automatically install Drupal and the Linux Apache MySQL stack after your VirtualBox is started. If you added a Vagrantfile previously, you can delete it now. You're going to add a smaller, more customized one that is available from the Salty-Vagrant project page at https://github.com/saltstack/salty-vagrant. You simply can copy and paste this into a new Vagrantfile.
Locate the line
config.vm.box = "precise64" and
to the name of your box. If you've been following along, earlier in the
tutorial, I exported my box as
I also like to add guest/host network communications with this line to my Vagrantfile too:
config.vm.network :hostonly, "192.168.33.19"
You can use any available IP address for your internal VirtualBox network. Keep in mind, this is separate from your own network and is created by VirtualBox. This allows you to access your Drupal site from your own operating system's Web browser using the IP address that you specified. You can choose another IP address if you want.
Create Your Minion Configuration File
In the same directory as your Vagrantfile, create a salt directory, srv directory and lamp-drupal directory like this:
mkdir -p salt/srv/lamp-drupal
Create a new minion.conf file in your salt directory that contains this line:
This instructs Salt not to search for a master server, but instead to use the local file structure for its configuration information. This is what you'll see referred to in the Salt Stack documentation as a masterless configuration.
Locate the line in your Vagrantfile labeled salt.minion_conf and uncomment it by removing the #. This tells Vagrant where your minion configuration is located. The path is relative to your Vagrantfile.
Get the State Files
My Drupal SLS file is available in the salt-states repository. You can use this to install all of the needed packages in Ubuntu for Drupal development. Download that file now and place it in your /srv/salt/lamp-drupal directory. You'll also need to create a /srv/salt/top.sls file that looks like this:
base: '*': - lamp-drupal
For more details about the top file, see my previously mentioned article about installing Salt Stack.
Add the State File to Your Shared Folder
Within the salt/srv/lamp-drupal directory, copy the init.sls file from the salt-states repository.
This file instructs Salt that when the machine is booted to install all of the needed packages for running a Drupal Web server. I've even included a Drush installation. If you examine the file, you'll find that it is fairly understandable already. I won't go into much more detail here, but feel free to take a look at the init.sls file to see what actually is being installed.
Now edit your Vagrantfile to reflect the location of this state file by editing the line:
config.vm.share_folder "salt_file_root", "/srv", ↪"/path/to/salt_file_root"
config.vm.share_folder "salt_file_root", "/srv/salt", "salt/srv"
With your minion configuration file in place and your state file ready to go, this last step will start your machine automatically, install Salt and install all of the necessary components needed for a Drupal development server.
vagrant up to start your machine.
You can watch the output and responses as Vagrant, Salty-Vagrant and Salt Stack automatically download all of the software you specified and configure it for you.
After the server is started, simply SSH to your virtual server using
vagrant ssh again. You'll find a /var/www folder ready to receive
your Drupal installation.
This SLS file is reusable across multiple environments, and I haven't configured it to change the permissions of the /var/www folder. You'll notice this folder is owned by root, just like the Ubuntu package manager sets it.
The Drush directory located within the vagrant user's home directory is also owned by root. You'll get an error with Drush if you don't change the ownership of that folder to the user that is initiating the Drush command.
By combining four very powerful tools: Vagrant, Salty-Vagrant, VirtualBox and Salt, you can speed up your Drupal development considerably. Maintaining small development environments and then scripting their configuration helps create a win for everyone involved by adding consistency across all your developers' platforms. Maintaining small, text-based configuration files can save money on storage costs too. You and your developers also can save time transferring new configurations to remote servers.
You can try out new configurations and install additional libraries if you need or want to, without fear of breaking your local or production systems.
Each of the tools I have outlined are available for no cost and are open-source projects. You'll find the Salt development community to be one of the friendliest and most welcoming communities around the Open Source world.
Each project is updated on a regular basis, and it would be a good idea to review the documentation, as well as changes to the software, if you encounter any problems.
Ben Hosmer is a DEVOP with RadiantBlue Technologies where he develops and maintains Drupal sites and administers various servers. He is an open-source advocate and helps spread the use of Linux and other open-source software within the US government.
Pick up any e-commerce web or mobile app today, and you’ll be holding a mashup of interconnected applications and services from a variety of different providers. For instance, when you connect to Amazon’s e-commerce app, cookies, tags and pixels that are monitored by solutions like Exact Target, BazaarVoice, Bing, Shopzilla, Liveramp and Google Tag Manager track every action you take. You’re presented with special offers and coupons based on your viewing and buying patterns. If you find something you want for your birthday, a third party manages your wish list, which you can share through multiple social- media outlets or email to a friend. When you select something to buy, you find yourself presented with similar items as kind suggestions. And when you finally check out, you’re offered the ability to pay with promo codes, gifts cards, PayPal or a variety of credit cards.Get the Guide
|openHAB||Apr 24, 2017|
|Omesh Tickoo and Ravi Iyer's Making Sense of Sensors (Apress)||Apr 21, 2017|
|Low Power Wireless: 6LoWPAN, IEEE802.15.4 and the Raspberry Pi||Apr 20, 2017|
|CodeLathe's Tonido Personal Cloud||Apr 19, 2017|
|Wrapping Up the Mars Lander||Apr 18, 2017|
|MultiTaction's MT Canvus-Connect||Apr 17, 2017|
- Teradici's Cloud Access Platform: "Plug & Play" Cloud for the Enterprise
- The Weather Outside Is Frightful (Or Is It?)
- Low Power Wireless: 6LoWPAN, IEEE802.15.4 and the Raspberry Pi
- Simple Server Hardening
- Understanding Firewalld in Multi-Zone Configurations
- Bash Shell Script: Building a Better March Madness Bracket
- Non-Linux FOSS: Control Web-Based Music!
- Gordon H. Williams' Making Things Smart (Maker Media, Inc.)