Advertisement
Guest User

Untitled

a guest
Dec 20th, 2021
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1.  
  2. ---
  3. Vagrantfile.yaml:
  4. ---
  5. box_image: 'ubuntu-20.04_mini-20211220c'
  6. interface: 'eno1'
  7. systems:
  8. smar002: ''
  9. delf003: ''
  10.  
  11. ---
  12. Vagrantfile:
  13. ---
  14. # -*- mode: ruby -*-
  15. # vi: set ft=ruby :
  16.  
  17. require 'yaml'
  18.  
  19. current_dir = File.dirname(File.expand_path(__FILE__))
  20. myconfigs = YAML.load_file("#{current_dir}/Vagrantfile.yaml")
  21.  
  22. myhostnames = myconfigs['systems']
  23. myinterface = myconfigs['interface']
  24. mybox_image = myconfigs['box_image']
  25.  
  26. Vagrant.configure("2") do |config|
  27. myhostnames.each do |i,x|
  28. config.vm.boot_timeout = 900
  29. config.vm.define vm_name = "#{i}" do |subconfig|
  30. subconfig.vm.box = mybox_image
  31. subconfig.ssh.username = "vmadmin"
  32. subconfig.ssh.password = "vmadmin"
  33. subconfig.vm.hostname = "#{i}"
  34. subconfig.vm.network :public_network, auto_config: false, bridge: myinterface
  35. subconfig.vm.provision "shell", inline: <<-SHELL
  36. /bin/touch /tmp/firstrun
  37. SHELL
  38. subconfig.vm.provider "virtualbox" do |v|
  39. v.name = vm_name
  40. v.customize ["modifyvm", :id, "--paravirtprovider", "kvm"]
  41. v.customize ["modifyvm", :id, "--autostart-enabled", "on"]
  42. v.customize ["modifyvm", :id, "--nictype1", "virtio"]
  43. v.customize ["modifyvm", :id, "--nictype2", "virtio"]
  44. end
  45. #
  46. # https://superuser.com/questions/1338429/how-do-i-reboot-a-vagrant-guest-from-a-provisioner
  47. #
  48. #subconfig.trigger.after [:provision] do |t|
  49. # t.name = "Reboot after provisioning"
  50. # t.run = { :inline => "vagrant reload" }
  51. #end
  52. #config.vm.provision :shell do |shell|
  53. # shell.privileged = true
  54. # shell.inline = 'echo rebooting'
  55. # shell.reboot = true
  56. #end
  57. end
  58. end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement