Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- Vagrantfile.yaml:
- ---
- box_image: 'ubuntu-20.04_mini-20211220c'
- interface: 'eno1'
- systems:
- smar002: ''
- delf003: ''
- ---
- Vagrantfile:
- ---
- # -*- mode: ruby -*-
- # vi: set ft=ruby :
- require 'yaml'
- current_dir = File.dirname(File.expand_path(__FILE__))
- myconfigs = YAML.load_file("#{current_dir}/Vagrantfile.yaml")
- myhostnames = myconfigs['systems']
- myinterface = myconfigs['interface']
- mybox_image = myconfigs['box_image']
- Vagrant.configure("2") do |config|
- myhostnames.each do |i,x|
- config.vm.boot_timeout = 900
- config.vm.define vm_name = "#{i}" do |subconfig|
- subconfig.vm.box = mybox_image
- subconfig.ssh.username = "vmadmin"
- subconfig.ssh.password = "vmadmin"
- subconfig.vm.hostname = "#{i}"
- subconfig.vm.network :public_network, auto_config: false, bridge: myinterface
- subconfig.vm.provision "shell", inline: <<-SHELL
- /bin/touch /tmp/firstrun
- SHELL
- subconfig.vm.provider "virtualbox" do |v|
- v.name = vm_name
- v.customize ["modifyvm", :id, "--paravirtprovider", "kvm"]
- v.customize ["modifyvm", :id, "--autostart-enabled", "on"]
- v.customize ["modifyvm", :id, "--nictype1", "virtio"]
- v.customize ["modifyvm", :id, "--nictype2", "virtio"]
- end
- #
- # https://superuser.com/questions/1338429/how-do-i-reboot-a-vagrant-guest-from-a-provisioner
- #
- #subconfig.trigger.after [:provision] do |t|
- # t.name = "Reboot after provisioning"
- # t.run = { :inline => "vagrant reload" }
- #end
- #config.vm.provision :shell do |shell|
- # shell.privileged = true
- # shell.inline = 'echo rebooting'
- # shell.reboot = true
- #end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement