Skip to content

Instantly share code, notes, and snippets.

@andir
Created Apr 22, 2017
Embed
What would you like to do?
hackint vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
SERVERS = [
'gilbert.hackint.org',
'sullivan.hackint.org'
]
SUBNET = "10.10.0"
required_plugins = {
'vagrant-hostmanager' => '~>1.8.5',
}
needs_restart = false
required_plugins.each do |name, version|
unless Vagrant.has_plugin? name, version
system "vagrant plugin install #{name} --plugin-version=\"#{version}\""
needs_restart = true
end
end
if needs_restart
exec "vagrant #{ARGV.join' '}"
end
Vagrant.configure(2) do |config|
config.vm.box = "bento/debian-8.7"
# Bootstrap the hackint salt-master
#
config.vm.define :master do |salt|
salt.vm.synced_folder "salt", "/srv/salt"
salt.vm.synced_folder "pillar", "/srv/pillar"
salt.vm.hostname = 'salt'
salt.vm.network :private_network, ip: "10.10.0.5"
#salt.vm.network :forwarded_port, guest: 22, host: 2220, auto_correct: true
config.vm.provision :salt do |config|
config.minion_config = "vagrant/minion"
config.master_config = "vagrant/master"
config.minion_key = "vagrant/keys/minion.pem"
config.minion_pub = "vagrant/keys/minion.pub"
config.master_key = "vagrant/keys/master.pem"
config.master_pub = "vagrant/keys/master.pub"
keys = { salt: config.master_pub }
SERVERS.each do |server_name|
keys = keys.merge("#{server_name}": config.minion_pub)
end
config.seed_master = keys
config.install_master = true
config.always_install = true
config.verbose = true
config.run_highstate = true
end
end
# Bootstrap hackint servers
#
SERVERS.each_with_index do |server_name, num|
server = server_name
config.vm.define server do |minion|
minion.vm.hostname = "#{server}"
minion.vm.network :private_network, ip: "#{SUBNET}.#{num + 10}"
minion.vm.synced_folder "vagrant/keys/", "/etc/salt/keys"
#minion.vm.network :forwarded_port, guest: 22, host: 2221, auto_correct: true
minion.vm.provision :salt do |config|
config.install_master = false
config.minion_config = "vagrant/minion"
config.minion_key = "vagrant/keys/minion.pem"
config.minion_pub = "vagrant/keys/minion.pub"
config.verbose = true
config.bootstrap_options = "-D"
end
end
end
# Update the VMs /etc/host files to know each other
#
config.hostmanager.enabled = true
config.hostmanager.manage_guest = true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment