Last active
January 3, 2018 23:14
-
-
Save kikitux/ee20aa07d9534841e103 to your computer and use it in GitHub Desktop.
vagrant-sphere sample 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
#settings for vm | |
#name of vm to current directory | |
vm_prefix = Pathname.new(Dir.getwd).basename.to_s | |
vm_folder = "vagrant-vsphere/#{vm_prefix}" | |
vm_number = 3 | |
vm_ram = 1024 | |
vm_cpu = 2 | |
vm_datastore = "sas" | |
#scripts | |
$provision_first = <<SCRIPT | |
echo "Provisioning run on first vm $HOSTNAME" | |
rm -fr /etc/udev/rules.d/70-persistent-net.rules | |
SCRIPT | |
$provision_all = <<SCRIPT | |
echo "Provisioning run for all vm on $HOSTNAME" | |
rm -fr /etc/udev/rules.d/70-persistent-net.rules | |
SCRIPT | |
Vagrant.configure("2") do |config| | |
#start of common block | |
config.vm.box = 'dummy' | |
config.vm.box_url = '../dummy.box' | |
config.vm.synced_folder ".", "/vagrant", disabled: true | |
config.vm.synced_folder "../../work/alvaro", "/alvaro", create: true, type: "rsync" | |
config.vm.provision "shell", run: "always", inline: $provision_all | |
config.ssh.username = 'root' | |
config.ssh.password = 'root' | |
config.ssh.forward_x11 = true | |
config.vm.provider :vsphere do |vsphere| | |
vsphere.data_store_name = vm_datastore | |
vsphere.memory_mb = vm_ram | |
vsphere.cpu_count = vm_cpu | |
vsphere.host = '10.10.10.10' | |
vsphere.insecure = true | |
vsphere.data_center_name = 'NZ' | |
vsphere.compute_resource_name = 'servername' | |
vsphere.user = 'user@domain' | |
vsphere.password = 'Password123' | |
end | |
#end of common block | |
#first box from template | |
config.vm.define vm_base = "#{vm_prefix}1" do |config| | |
config.vm.hostname = vm_base | |
config.vm.provision "shell", run: "always", inline: $provision_first | |
config.vm.provider :vsphere do |vsphere| | |
vsphere.vm_base_path = vm_folder | |
vsphere.name = vm_base | |
vsphere.template_name = 'Templates/oracle6-template' | |
vsphere.linked_clone = false | |
end | |
end | |
#second and the rest linked clone from first one | |
(2..vm_number).each do |i| | |
config.vm.define vm_name = "#{vm_prefix}%01d" % i do |config| | |
config.vm.hostname = vm_name | |
config.vm.provider :vsphere do |vsphere| | |
vsphere.vm_base_path = vm_folder | |
vsphere.name = vm_name | |
vsphere.template_name = "#{vm_folder}/#{vm_prefix}1" | |
vsphere.linked_clone = true | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment