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

Add remove_cdrom to vmware-iso #10704

Closed
jeremymcgee73 opened this issue Feb 26, 2021 · 5 comments
Closed

Add remove_cdrom to vmware-iso #10704

jeremymcgee73 opened this issue Feb 26, 2021 · 5 comments

Comments

@jeremymcgee73
Copy link

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

I would like to be able to use remove_cdrom with the vmware-iso provider. I am adding a disk using cd_files with vmware-iso, then I am use vmware-vmx to import the vmx, do some more config and convert to ova. However, the conversion fails because the temporary ISO no longer exists. I would like to cleanup the CD drive in the vmware-iso run. I may be able to fix this with ovftool_options, but have not gotten that to work yet.

Use Case(s)

Potential configuration

Potential References

@jeremymcgee73
Copy link
Author

The root of this, may actually be a bug with cd_files. I will look at this some more, and maybe open a bug issue. The drive does not get removed from the VMX like the floppy does.

@saleemrashid
Copy link

saleemrashid commented Mar 12, 2021

Annoyingly, if you try to export the vmware-iso to OVA, the temporarily ISO will be included in the OVA and you can't work around this with vmx_data_post because the handling of cdrom_files overrides it.

However, in your specific situation, you can probably work around it temporarily by adding something like "ide1:0.present" = "FALSE" to vmx_data in your vmware-vmx source (since the vmware-vmx source won't have cdrom_files set).

I haven't tested it, but the fix for this should be as simple as appending the device to the "temporaryDevices" state item. e.g., similarly to append(tmpBuildDevices, "floppy0"), you'd have append(tmpBuildDevices, cdromPrefix).

// Set a floppy disk, but only if we should
if !s.SkipFloppy {
// Grab list of temporary builder devices so we can append the floppy to it
tmpBuildDevices := state.Get("temporaryDevices").([]string)
// Set a floppy disk if we have one
if floppyPathRaw, ok := state.GetOk("floppy_path"); ok {
log.Println("Floppy path present, setting in VMX")
vmxData["floppy0.present"] = "TRUE"
vmxData["floppy0.filetype"] = "file"
vmxData["floppy0.filename"] = floppyPathRaw.(string)
// Add it to our list of build devices to later remove
tmpBuildDevices = append(tmpBuildDevices, "floppy0")
}
// Build the list back in our statebag
state.Put("temporaryDevices", tmpBuildDevices)
}
// Add our custom CD, if it exists
if cdPath, ok := state.GetOk("cd_path"); ok {
if cdPath != "" {
diskAndCDConfigData := DefaultDiskAndCDROMTypes(s.DiskAdapterType, s.CDROMAdapterType)
cdromPrefix := diskAndCDConfigData.CDROMType + "1:" + diskAndCDConfigData.CDROMType_PrimarySecondary
vmxData[cdromPrefix+".present"] = "TRUE"
vmxData[cdromPrefix+".fileName"] = cdPath.(string)
vmxData[cdromPrefix+".deviceType"] = "cdrom-image"
}
}

@SwampDragons SwampDragons added this to the 1.7.2 milestone Mar 16, 2021
@jeremymcgee73
Copy link
Author

I think I tried that! For now I'm using grep to remove it. Grep can't overwrite a file, so i just write it to tmp.

 post-processor "shell-local" {
    environment_vars = ["VMXPATH=builds/base.vmx"]
    inline = [
      "grep -v '^ide1:0' $VMXPATH > /tmp/base.vmx",
      "mv /tmp/base.vmx ./builds/base.vmx"
    ]
  }

@github-actions
Copy link

This issue has been migrated to hashicorp/packer-plugin-vmware#33 due to the Packer Plugin split.

Please follow the new issue for updates.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants