Provisioning Vagrant with Salt

Vagrant sports out of the box integration with Saltstack, which works very well with minimum effort. However under the hood the default way this integration works is via a 4000-line bash script that bootstraps Saltstack on the VM. This would all be well and good, however, even if you were to pre-install the salt-call and salt-minion binaries onto your Vagrantbox, the salt-integration uses the same bash-script to install the configuration provided in the Vagrantfile.

So it has come to this..    I don’t really want this in my workflow. And I suspect any heavy Saltstack users might want to skip this aswell.

I found a way, that was not completely obvious, to make the Salt-integration work as quick and painless as I wanted in the Masterless mode:

  • Create a vagrantbox (in my case I use Packer with a set of templates), with the salt-binaries pre-installed.
  • Make sure the salt-minion daemon is disabled.
  • Overwrite the default minion config with the contents  “file_client: local” (and of course any other configuration you require)

This way you do not have to use the “minion_config” setting in your Vagrantfile, and the salt provisioner plugin will happily skip the bootstrapping script.

You could always check the Saltstack installation-script for the Packer-template for reference.

You can now use the following setup in your Vagrantfile:

config.vm.synced_folder "salt/roots/", "/srv/salt/"

config.vm.provision :salt do |salt|
  salt.run_highstate = true
end

In salt/roots/ place your top.sls which could look something like this:

base:
  '*':
    - default

Which would then execute the salt/roots/default/init.sls state.