Vagrant, Saltstack & “saltyvagrant”

I was banging against Vagrant’s preferred way of doing salt deployments. Horrible nasty huge bash scripts that cater for every possibility.

I just wanted to spin up: 

  • a reasonably modern Ubuntu version
  • set it up as a master/minion on the same machine
  • copy in my salt master config and my salt minion config
  • call salt -v "*" state.highstate

Strange things would fail. I was filled with sadness.

Then I fixed things.

Add the following lines to your Vagrantfile:

export DEBIAN_FRONTEND=noninteractive
apt-get --yes -q install python-software-properties
add-apt-repository ppa:saltstack/salt2015-5 -y
apt-get --yes -q update
mkdir /etc/salt
apt-get --yes -q install python-git salt-master salt-minion
cp /srv/vagrant_salt_bootstrap/master /etc/salt/master
cp /srv/vagrant_salt_bootstrap/minion /etc/salt/minion
restart salt-minion
restart salt-master
sleep 10
salt-key -y -a '*'
sleep 10
salt -v "*" state.highstate -l debug

call this from your Vagrantfile with the following configuration:

config.vm.synced_folder "saltstack/vagrant_salt_bootstrap", "/srv/vagrant_salt_bootstrap"
config.vm.provision :shell, :inline => "sudo /srv/vagrant_salt_bootstrap/"

You can see it in action in the buddycloud-vm project.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.