Any interest to create box with 2 hdd?
rubisher opened this issue · 2 comments
Describe the Enhancement
Looking to create a custom vagrant box with 2 hdd.
Describe the Need
To be able to create an Ansible lab with VM like in our prod ;)
Current Alternative
The alternate stand in a cutom vboxmanage var like:
vboxmanage = [
[
"createmedium", "disk",
"--format", "VDI",
"--filename", "disk_02.vdi",
"--size", "69632",
],
[
"storageattach", "{{.Name}}",
"--storagectl", "SATA Controller",
"--port", "1", "--type", "hdd",
"--medium", "disk_02.vdi",
]
]
but 'packer' is able to manage more efficiently (imho)?
Can We Help You Implement This
I just have to add a new var definition like:
$ diff -Nau ./packer_templates/pkr-variables.pkr.hcl.orig ./packer_templates/pkr-variables.pkr.hcl
--- ./packer_templates/pkr-variables.pkr.hcl.orig 2023-08-13 10:00:17.961302325 +0000
+++ ./packer_templates/pkr-variables.pkr.hcl 2023-08-13 09:52:40.861863424 +0000
@@ -146,6 +146,10 @@
default = null
description = "OS type for virtualization optimization"
}
+variable "vbox_disk_additional_size" {
+ type = list(number)
+ default = null
+}
variable "vbox_hard_drive_interface" {
type = string
default = "sata"
to be able to add it to the 'source "virtualbox-iso" "vm" ' like:
$ diff -Nau ./packer_templates/pkr-sources.pkr.hcl.orig ./packer_templates/pkr-sources.pkr.hcl
--- ./packer_templates/pkr-sources.pkr.hcl.orig 2023-08-13 10:01:10.383063531 +0000
+++ ./packer_templates/pkr-sources.pkr.hcl 2023-08-13 21:40:09.252571972 +0000
@@ -221,6 +221,7 @@
boot_wait = local.boot_wait
cpus = var.cpus
communicator = local.communicator
+ disk_additional_size = var.vbox_disk_additional_size == null ? [] : var.vbox_disk_additional_size
disk_size = var.disk_size
floppy_files = local.floppy_files
headless = var.headless
and also add its requirement in a custome os_pkrvars/centos/rudy-centos-7-x86_64.pkrvars.hcl:
vbox_disk_additional_size = [ 69632 ]
After a quick run, it seems that the box contains well the 2 virtual disks I wanted:
$ tar -tlpvf ./packer_templates/../builds/centos-7.9-x86_64.virtualbox.box
-rw-r--r-- jlst/sysadmins 258 2023-08-13 10:09 Vagrantfile
-rw-r--r-- jlst/sysadmins 7722 2023-08-13 10:09 box.ovf
-rw-r--r-- jlst/sysadmins 469114880 2023-08-13 10:09 centos-7.9-amd64-disk001.vmdk
-rw-r--r-- jlst/sysadmins 76288 2023-08-13 10:09 centos-7.9-amd64-disk002.vmdk
-rw-r--r-- jlst/sysadmins 26 2023-08-13 10:09 metadata.json
PS: I think that we would need different var for each type of VM tool (not sure but qm would need a list(string)?)
Take care,
Rudy
Adding the feature doesn't hurt anything so I'm open to PR's to help implement. We won't be modifying the default OS templates and publishing them with multiple drives to the bento vagrant hub account though. Those boxes are meant to be simple install for temporary testing purposes.
Closing due to lack of activity.