From 2a121065036e2f30e5cec073f234045dcc509571 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Thu, 8 Sep 2016 23:28:24 +0200 Subject: [PATCH] Make Vagrantfile work again Debian Vagrant base images no longer include python and ca-certificates, which are useful to bootstrap salt. Also the support of the salt provider in Vagrant changed slightly and no longer worked with Vagrant 1.8.5. While at it, document the command line to run Vagrant with a libvirt backend. --- test-vagrant-salt/NOTES.rst | 4 ++++ test-vagrant-salt/Vagrantfile | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test-vagrant-salt/NOTES.rst b/test-vagrant-salt/NOTES.rst index 59aa4f1..e58a42d 100644 --- a/test-vagrant-salt/NOTES.rst +++ b/test-vagrant-salt/NOTES.rst @@ -15,6 +15,10 @@ Quick commands vagrant up +* Start a VM using libvirt provider instead of VirtualBox:: + + vagrant up --provider=libvirt + * SSH into a VM:: vagrant ssh gateway diff --git a/test-vagrant-salt/Vagrantfile b/test-vagrant-salt/Vagrantfile index 46c7514..25fbaf3 100644 --- a/test-vagrant-salt/Vagrantfile +++ b/test-vagrant-salt/Vagrantfile @@ -13,12 +13,17 @@ Vagrant.configure(2) do |config| gateway_config.vm.network "private_network", ip: "192.168.33.2" gateway_config.vm.synced_folder "salt/", "/srv/salt" + # Salt bootstrap needs Python and SSL certificates + gateway_config.vm.provision :shell, + inline: "sudo apt-get -qq update && sudo apt-get install -qqy python ca-certificates" + gateway_config.vm.provision :salt do |salt| salt.minion_config = "saltconfig" salt.install_type = "stable" salt.masterless = true salt.verbose = true salt.colorize = true + salt.run_highstate = true # https://github.com/mitchellh/vagrant/issues/5973#issuecomment-137276605 salt.bootstrap_options = "-F -c /tmp/ -P" end @@ -33,15 +38,22 @@ Vagrant.configure(2) do |config| testvm_config.vm.synced_folder "saltpillar/", "/srv/saltpillar" # Change the default route to the gateway VM - testvm_config.vm.provision "shell", + # The host may need to adjust its firewall to prevent packets between VMs from being NAT'ed: + # iptables -t nat -I POSTROUTING -o 'virbr+' -s 192.168.33.0/24 -j RETURN + testvm_config.vm.provision :shell, inline: "sudo ip route delete default ; sudo ip route add default via 192.168.33.2" + # Salt bootstrap needs SSL certificates + testvm_config.vm.provision :shell, + inline: "sudo apt-get -qq update && sudo apt-get install -qqy ca-certificates" + testvm_config.vm.provision :salt do |salt| salt.minion_config = "saltconfig" salt.install_type = "stable" salt.masterless = true salt.verbose = true salt.colorize = true + salt.run_highstate = true salt.bootstrap_options = "-F -c /tmp/ -P" end end -- 2.1.4