Created
January 3, 2016 10:02
-
-
Save kikitux/805f58ae1f7fb30e5109 to your computer and use it in GitHub Desktop.
2 node Vagrantfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#configuration of host resolv | |
$resolv = <<-EOF | |
cat > /etc/resolv.conf <<EOF2 | |
search local | |
nameserver 127.0.0.1 | |
EOF2 | |
EOF | |
$hosts = <<-EOF | |
cat > /etc/hosts <<EOF2 | |
127.0.0.1 localhost.localdomain localhost | |
::1 localhost.localdomain localhost | |
192.168.1.11 agent1.local agent1 | |
192.168.1.12 agent2.local agent2 | |
EOF2 | |
EOF | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
Vagrant.configure("2") do |config| | |
config.vm.box_check_update = true | |
config.ssh.insert_key = false | |
# Virtualbox | |
config.vm.provider "virtualbox" do |v| | |
v.cpus = "2" | |
v.memory = "1024" | |
end | |
#resolv.conf and hosts | |
config.vm.provision "shell", inline: $resolv, run: always | |
config.vm.provision "shell", inline: $hosts, run: always | |
#config.vm.provision "shell", inline: "which dnsmasq || apt-get install -y dnsmasq" | |
#agent box | |
(1..3).each do |i| | |
vm_name = "agent#{i}.local" | |
config.vm.define vm_name do |agent| | |
agent.vm.box = "hashicorp/precise64" | |
agent.vm.hostname = vm_name | |
ip="192.168.10.#{10+i}" | |
agent.vm.network "private_network", ip: ip | |
agent.vm.network "forwarded_port", guest: 80, host: 8000+i | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment