25fbaf34ae2753622e9f377a5344a43309d8598a
[vagrant-mail.git] / test-vagrant-salt / Vagrantfile
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
3
4 # All Vagrant configuration is done below. The "2" in Vagrant.configure
5 # configures the configuration version (we support older styles for
6 # backwards compatibility). Please don't change it unless you know what
7 # you're doing.
8 Vagrant.configure(2) do |config|
9   # Filtering gateway of the virtual machine
10   config.vm.define :gateway do |gateway_config|
11     gateway_config.vm.box = "debian/jessie64"
12     gateway_config.vm.host_name = "gateway"
13     gateway_config.vm.network "private_network", ip: "192.168.33.2"
14     gateway_config.vm.synced_folder "salt/", "/srv/salt"
15
16     # Salt bootstrap needs Python and SSL certificates
17     gateway_config.vm.provision :shell,
18       inline: "sudo apt-get -qq update && sudo apt-get install -qqy python ca-certificates"
19
20     gateway_config.vm.provision :salt do |salt|
21       salt.minion_config = "saltconfig"
22       salt.install_type = "stable"
23       salt.masterless = true
24       salt.verbose = true
25       salt.colorize = true
26       salt.run_highstate = true
27       # https://github.com/mitchellh/vagrant/issues/5973#issuecomment-137276605
28       salt.bootstrap_options = "-F -c /tmp/ -P"
29     end
30   end
31
32   # Test virtual machine to run things
33   config.vm.define :testvm do |testvm_config|
34     testvm_config.vm.box = "debian/jessie64"
35     testvm_config.vm.host_name = "testvm"
36     testvm_config.vm.network "private_network", ip: "192.168.33.10"
37     testvm_config.vm.synced_folder "salt/", "/srv/salt"
38     testvm_config.vm.synced_folder "saltpillar/", "/srv/saltpillar"
39
40     # Change the default route to the gateway VM
41     # The host may need to adjust its firewall to prevent packets between VMs from being NAT'ed:
42     #     iptables -t nat -I POSTROUTING -o 'virbr+' -s 192.168.33.0/24 -j RETURN
43     testvm_config.vm.provision :shell,
44       inline: "sudo ip route delete default ; sudo ip route add default via 192.168.33.2"
45
46     # Salt bootstrap needs SSL certificates
47     testvm_config.vm.provision :shell,
48       inline: "sudo apt-get -qq update && sudo apt-get install -qqy ca-certificates"
49
50     testvm_config.vm.provision :salt do |salt|
51       salt.minion_config = "saltconfig"
52       salt.install_type = "stable"
53       salt.masterless = true
54       salt.verbose = true
55       salt.colorize = true
56       salt.run_highstate = true
57       salt.bootstrap_options = "-F -c /tmp/ -P"
58     end
59   end
60 end