Skip to content

Instantly share code, notes, and snippets.

@bunchc
Created April 28, 2015 20:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bunchc/7a630059e35404b2c26f to your computer and use it in GitHub Desktop.
Save bunchc/7a630059e35404b2c26f to your computer and use it in GitHub Desktop.
Multi-Node Salt Minions & Master
export DEBIAN_FRONTEND=noninteractive
# Setup Master
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y vim git curl wget
curl -L http://bootstrap.saltstack.org | sudo sh -s -- -M
sudo sed -i 's/#auto_accept: False/auto_accept: True/g' /etc/salt/master
sudo service salt-master restart
master: 172.17.0.200
file_client: remote
# -*- mode: ruby -*-
# vi: set ft=ruby :
# If container_sync
# enable swift2
# configure swift and swift2 with container_sync configs (execute extra script at end)
# If dvr
# enable compute2
# configure compute and compute2 for dvr
# Uncomment the next line to force use of VirtualBox provider when Fusion provider is present
# ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
nodes = {
'master' => [1, 200],
'minion' => [1, 201],
}
Vagrant.configure("2") do |config|
# Virtualbox
config.vm.box = "hashicorp/precise64"
config.vm.synced_folder ".", "/vagrant", type: "nfs"
# VMware Fusion / Workstation
config.vm.provider :vmware_fusion or config.vm.provider :vmware_workstation do |vmware, override|
override.vm.box = "hashicorp/precise64"
override.vm.synced_folder ".", "/vagrant", type: "nfs"
# Fusion Performance Hacks
vmware.vmx["logging"] = "FALSE"
vmware.vmx["MemTrimRate"] = "0"
vmware.vmx["MemAllowAutoScaleDown"] = "FALSE"
vmware.vmx["mainMem.backing"] = "swap"
vmware.vmx["sched.mem.pshare.enable"] = "FALSE"
vmware.vmx["snapshot.disabled"] = "TRUE"
vmware.vmx["isolation.tools.unity.disable"] = "TRUE"
vmware.vmx["unity.allowCompostingInGuest"] = "FALSE"
vmware.vmx["unity.enableLaunchMenu"] = "FALSE"
vmware.vmx["unity.showBadges"] = "FALSE"
vmware.vmx["unity.showBorders"] = "FALSE"
vmware.vmx["unity.wasCapable"] = "FALSE"
vmware.vmx["vhv.enable"] = "TRUE"
end
#Default is 2200..something, but port 2200 is used by forescout NAC agent.
config.vm.usable_port_range= 2800..2900
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
config.cache.enable :apt
config.cache.synced_folder_opts = {
type: :nfs,
mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
}
else
puts "[-] WARN: This would be much faster if you ran vagrant plugin install vagrant-cachier first"
end
nodes.each do |prefix, (count, ip_start)|
count.times do |i|
hostname = "%s-%02d" % [prefix, (i+1)]
config.vm.define "#{hostname}" do |box|
box.vm.hostname = "#{hostname}.cook.book"
box.vm.network :private_network, ip: "172.17.0.#{ip_start+i}", :netmask => "255.255.0.0"
if prefix == "master"
box.vm.provision :shell, :path => "#{prefix}.sh"
else
box.vm.provision :salt do |salt|
salt.run_highstate = true
salt.minion_config = "./minion.conf"
#salt.minion_key = "./minion.pem"
#salt.minion_pub = "./minion.pub"
end
end
# If using Fusion or Workstation
box.vm.provider :vmware_fusion or box.vm.provider :vmware_workstation do |v|
v.vmx["memsize"] = 1024
end
# Otherwise using VirtualBox
box.vm.provider :virtualbox do |vbox|
# Defaults
vbox.customize ["modifyvm", :id, "--memory", 1024]
vbox.customize ["modifyvm", :id, "--cpus", 1]
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment