Vagrantfile resize handling
This implements the resize in a more "vagrant way", by using a plugin that is meant for resizing the instance's disk. Advantages: - We don't have to ship the resize code contnet - It works when stopping the machine and starting it up again. Change-Id: I4f725131f15c57f176201aac0d967459792ebe5a
This commit is contained in:
parent
f02b5487bd
commit
407002f3f7
77
Vagrantfile
vendored
77
Vagrantfile
vendored
@ -2,47 +2,15 @@ Vagrant.configure(2) do |config|
|
||||
|
||||
config.vm.define "ubuntu1604" do |xenial|
|
||||
xenial.vm.box = "ubuntu/xenial64"
|
||||
# Expand the disk to 60GB. You'll need
|
||||
# the plugin disksize. Please run:
|
||||
# vagrant plugin install vagrant-disksize
|
||||
xenial.disksize.size = '60GB'
|
||||
xenial.vm.provider "virtualbox" do |v|
|
||||
|
||||
v.name = "OpenStack-Ansible_Ubuntu-16.04_#{Time.now.getutc.to_i}"
|
||||
v.memory = 8192
|
||||
v.cpus = 4
|
||||
|
||||
image_path = "#{ENV["HOME"]}/VirtualBox VMs/#{v.name}"
|
||||
image_name = 'ubuntu-xenial-16.04-cloudimg'
|
||||
|
||||
# We clone the image to a resizable format
|
||||
v.customize [
|
||||
"clonehd", "#{image_path}/#{image_name}.vmdk",
|
||||
"#{image_path}/#{image_name}.vdi",
|
||||
"--format", "VDI"
|
||||
]
|
||||
|
||||
# Then resize it to 60 GB
|
||||
v.customize [
|
||||
"modifymedium", "disk",
|
||||
"#{image_path}/#{image_name}.vdi",
|
||||
"--resize", 60 * 1024
|
||||
]
|
||||
|
||||
# Then attach it as the primary disk
|
||||
v.customize [
|
||||
"storageattach", :id,
|
||||
"--storagectl", "SCSI Controller",
|
||||
"--port", "0",
|
||||
"--device", "0",
|
||||
"--type", "hdd",
|
||||
"--nonrotational", "on",
|
||||
"--medium", "#{image_path}/#{image_name}.vdi"
|
||||
]
|
||||
|
||||
# Then remove the original disk
|
||||
v.customize [
|
||||
"closemedium", "disk",
|
||||
"#{image_path}/#{image_name}.vmdk",
|
||||
"--delete"
|
||||
]
|
||||
|
||||
# Now we can execute the build
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
sudo su -
|
||||
@ -55,47 +23,12 @@ Vagrant.configure(2) do |config|
|
||||
|
||||
config.vm.define "centos7" do |centos7|
|
||||
centos7.vm.box = "centos/7"
|
||||
centos7.disksize.size = '60GB'
|
||||
centos7.vm.provider "virtualbox" do |v|
|
||||
|
||||
v.name = "OpenStack-Ansible_CentOS-7_#{Time.now.getutc.to_i}"
|
||||
v.memory = 8192
|
||||
v.cpus = 4
|
||||
|
||||
image_path = "#{ENV["HOME"]}/VirtualBox VMs/#{v.name}"
|
||||
image_name = 'centos-7-1-1.x86_64'
|
||||
|
||||
# We clone the image to a resizable format
|
||||
v.customize [
|
||||
"clonehd", "#{image_path}/#{image_name}.vmdk",
|
||||
"#{image_path}/#{image_name}.vdi",
|
||||
"--format", "VDI"
|
||||
]
|
||||
|
||||
# Then resize it to 60 GB
|
||||
v.customize [
|
||||
"modifymedium", "disk",
|
||||
"#{image_path}/#{image_name}.vdi",
|
||||
"--resize", 60 * 1024
|
||||
]
|
||||
|
||||
# Then attach it as the primary disk
|
||||
v.customize [
|
||||
"storageattach", :id,
|
||||
"--storagectl", "IDE Controller",
|
||||
"--port", "0",
|
||||
"--device", "0",
|
||||
"--type", "hdd",
|
||||
"--nonrotational", "on",
|
||||
"--medium", "#{image_path}/#{image_name}.vdi"
|
||||
]
|
||||
|
||||
# Then remove the original disk
|
||||
v.customize [
|
||||
"closemedium", "disk",
|
||||
"#{image_path}/#{image_name}.vmdk",
|
||||
"--delete"
|
||||
]
|
||||
|
||||
# Now we can execute the build
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
sudo su -
|
||||
|
Loading…
x
Reference in New Issue
Block a user