Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3.  
  4. vms = [
  5. { "ip" => "192.168.0.254", "name" => "router" },
  6. { "ip" => "192.168.0.10" },
  7. { "ip" => "192.168.0.11" }
  8. ]
  9.  
  10. Vagrant.configure("2") do |config|
  11.  
  12. config.vm.provision "shell", inline: "echo Hello"
  13.  
  14. vms.each do |vm|
  15.  
  16. name = if vm["name"] then vm["name"] else vm["ip"] end
  17.  
  18. config.vm.define name do |node|
  19. # Box
  20. node.vm.box = "debian/jessie64"
  21.  
  22. # VM options
  23. node.vm.provider :virtualbox do |vb|
  24. vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
  25. vb.customize ["modifyvm", :id, "--memory", 256]
  26. vb.customize ["modifyvm", :id, "--cpus", 2]
  27. vb.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
  28. vb.customize ["modifyvm", :id, "--name", name]
  29. end
  30.  
  31. # Network
  32. node.vm.network "private_network", ip: vm["ip"]
  33.  
  34. # Add ssh_keys
  35. node.vm.provision "shell" do |s|
  36. ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip
  37. s.inline = <<-SHELL
  38. echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
  39. SHELL
  40. end
  41.  
  42. end
  43.  
  44. end
  45.  
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement