Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any interest to create box with 2 hdd? #1521

Open
rubisher opened this issue Aug 13, 2023 · 1 comment
Open

Any interest to create box with 2 hdd? #1521

rubisher opened this issue Aug 13, 2023 · 1 comment
Labels
Triage: Feature Request Indicates an issue requesting new functionality.

Comments

@rubisher
Copy link

rubisher commented Aug 13, 2023

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

@rubisher rubisher added the Status: Untriaged An issue that has yet to be triaged. label Aug 13, 2023
@Stromweld Stromweld added Triage: Feature Request Indicates an issue requesting new functionality. and removed Status: Untriaged An issue that has yet to be triaged. labels Aug 15, 2023
@Stromweld
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage: Feature Request Indicates an issue requesting new functionality.
Projects
None yet
Development

No branches or pull requests

2 participants