# -*- mode: ruby -*- # vi: set ft=ruby : if ! ( ENV['SCULLERY_BOX_NAME'] && ENV['SCULLERY_BOX_IMAGE'] ) || ! ( ENV['SCULLERY_MASTERS'] || ENV['SCULLERY_MINIONS'] ) print('Missing parameters') exit 1 end salt_bootstrap = "test/bootstrap-salt-roots.sh" Vagrant.configure("2") do |config| config.vm.provider "libvirt" config.vm.box = ENV['SCULLERY_BOX_NAME'] config.vm.box_url = ENV['SCULLERY_BOX_IMAGE'] config.vm.provision "shell", inline: <<-SHELL systemctl restart network SHELL if ENV['SCULLERY_MASTERS'] ENV['SCULLERY_MASTERS'].split(',').each do |vmname| config.vm.define "#{vmname}", primary: true do |master_config| master_config.vm.hostname = "#{vmname}" master_config.vm.provider :libvirt do |libvirt| libvirt.memory = 768 end master_config.vm.provision "shell", path: salt_bootstrap master_config.vm.provision "shell", inline: <<-SHELL printf 'auto_accept: True\n' > /etc/salt/master.d/notsecure.conf printf 'file_roots:\n base:\n - /srv/salt\n - /srv/formulas\n' > /etc/salt/master.d/roots.conf systemctl enable --now salt-master SHELL end end end if ENV['SCULLERY_MINIONS'] ENV['SCULLERY_MINIONS'].split(',').each do |vmname| config.vm.define "#{vmname}" do |minion_config| minion_config.vm.hostname = "#{vmname}" if ENV['SCULLERY_MASTERS'] minion_config.vm.synced_folder '.', '/vagrant', disabled: true minion_config.vm.provision "shell", inline: <<-SHELL sed -i 's/^#master:.*/master: scullery-master0/' /etc/salt/minion systemctl enable --now salt-minion SHELL else minion_config.vm.provision "shell", path: salt_bootstrap end end end end end