Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adnoh/b4fa6f1cc0ff86641d2e29ff2d215f80 to your computer and use it in GitHub Desktop.
Save adnoh/b4fa6f1cc0ff86641d2e29ff2d215f80 to your computer and use it in GitHub Desktop.
Using Vagrant with Salty-Vagrant and Multiple virtual machines
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.ssh.forward_agent = true
# Deployment instance salt master
config.vm.define :salt do |salt|
salt.vm.network :private_network, ip: "10.10.10.2"
salt.vm.hostname = 'master'
salt.vm.synced_folder "salt/roots/", "/srv/"
salt.vm.synced_folder "salt/key/", "/etc/salt/keys"
salt.vm.network :forwarded_port, guest: 22, host: 2220, auto_correct: true
salt.vm.provider "virtualbox" do |v|
v.name = "salt"
v.customize ["modifyvm", :id, "--memory", "1024"]
end
salt.vm.provision :salt do |config|
config.minion_config = "salt/minion"
config.master_config = "salt/master"
config.minion_key = "salt/key/minion.pem"
config.minion_pub = "salt/key/minion.pub"
config.master_key = "salt/key/master.pem"
config.master_pub = "salt/key/master.pub"
config.install_master = true
config.seed_master = {salt: "salt/key/master.pub", app0: "salt/key/minion.pub"}
config.run_highstate = false
config.accept_keys = true
config.verbose = true
config.bootstrap_options = "-D"
config.temp_config_dir = "/tmp"
end
end
# appX instance salt ninion
config.vm.define :app0 do |app0|
app0.vm.network :private_network, ip: "10.10.10.3"
app0.vm.hostname = "app0"
app0.vm.synced_folder "salt/key/", "/etc/salt/keys"
app0.vm.network :forwarded_port, guest: 22, host: 2221, auto_correct: true
app0.vm.provider "virtualbox" do |v|
v.name = "app0"
v.customize ["modifyvm", :id, "--memory", "1024"]
end
app0.vm.provision :salt do |config|
config.minion_config = "salt/minion"
config.minion_key = "salt/key/minion.pem"
config.minion_pub = "salt/key/minion.pub"
config.verbose = true
config.bootstrap_options = "-D"
config.temp_config_dir = "/tmp"
end
end
end

Description

Have you ever wanted to have a Vagrant workspace with more than one Virtual Machine, and managed by Salt Stack? I did, but the documentation is not all there yet.

I managed to make it work with the following, hope it will be useful.

To use

See the Complete salty-vagrant setup, but use the current Vagrantfile to have two machines.

Files in the workspace

Set the following files in your workspace, at the root of your web development project.

  • projectDir/Vagrantfile: The Vagrantfile from this gist
  • projectDir/salt/key: A few pem and pub files
  • projectDir/salt/roots: Checkout a few salt states as needed
  • projectDir/master: Salt master config, generally default do
  • projectDir/minion: Salt minion config, if master is called salt, no need to edit.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment