Closed tenthirtyam closed 8 months ago
Yes, it was an issue for me as well, but I settled on the reset and provided additional details in the comments for the docs. Using remove and keep didn't fit for me because it infers all. Using keep_one felt odd because that would limit the ability to expand the option later, if needed.
Do any other plugins have a similar feature?
@akutz what are your thoughts on the parameter name?
@akutz what are your thoughts on the parameter name?
What about one of (collapse|consolidate|keep|recreate|reset)_cdrom
that takes an int with the minimum and maximum of cdroms to keep in case of remove_cdrom = true
?
It could default to 0 (and maybe have a a maximum of the number of CD-ROMs that exist on the VM).
For a hypothetical packer VM with 3 CD-ROMs:
remove_cdrom = false
& keep_cdrom = 0
. Expected results: No CD-ROMs removed.
remove_cdrom = true
& keep_cdrom = 3
. Expected results: No CD-ROMs removed.
remove_cdrom = true
& keep_cdrom = 1
. Expected results: Single CD-ROM remains.
remove_cdrom = true
& keep_cdrom = 2
. Expected results: Two CD-ROMs remain.
I'll noodle this after the US Holiday week.
I'll noodle this after the US Holiday week.
Cool!
Another possibility is to add a "post-shutdown hardware configuration" that would let you alter the overall hardware of the VM before it is made into a template or exported, but I think that's more along the lines of a future feature request :)
Another possibility is to add a "post-shutdown hardware configuration" that would let you alter the overall hardware of the VM before it is made into a template or exported, but I think that's more along the lines of a future feature request :)
Might be a good post-processor.
@nywilken @lbajolet-hashicorp - I'm going to pick this one back up this week in my spare time.
@nywilken @lbajolet-hashicorp - I'm going to pick this one back up this week in my spare time.
Sounds good @tenthirtyam thanks for picking this back up. Feel free to ping when ready for review.
This pull request is ready for review but is failing for some reason on the Go Validate > Lint step.
cc @nywilken @lbajolet-hashicorp
@nywilken - I've made the requested changes we've discussed and pushed ff82b77 - let me know what you think.
One option might be to use the property reattach_cdrom
.
Ryan
@nywilken - per our Slack discussion, I've updated this to reflect reattach_cdroms
.
`reattach_cdroms` (int) - Reattach one or more configured CD-ROM devices. Range: 1-4.
You can reattach up to 4 CD-ROM devices to the final build artifact.
If set to 0, `reattach_cdroms` is ignored and the step is skipped.
When set to a value in the range, `remove_cdrom` is ignored and
the CD-ROM devices are reattached without any attached media.
Summary
Adds support for to reattach CD-ROMs on the image after the build completes without any attached media.
reattach_cdroma
is ignored and the step is skipped.reattach_cdroms
is set to a value in the range,remove_cdrom
is ignored and the CD-ROM devices are reattached without any attached media.Cherry-picks commits from @powertim in #326 and updates scope, prepare, and tests.
Tests
Standards Tests
Builds:
✅ Build with
remove_cdrom
=true
. Expected results: All CD-ROMs removed,reattach_cdroms
ignored. ✅ Build withreattach_cdroms
=0
andremove_cdrom
=false
. Expected results: All CD-ROMs kept,reattach_cdroms
ignored. ✅ Build withreattach_cdroms
=1
andremove_cdrom
=false
. Expected results: One CD-ROM remains. ✅ Build withreattach_cdroms
=1
andremove_cdrom
=true
. Expected results: One CD-ROM remains.reset_cdrom
is superceeded byreattach_cdrom
. ✅ Build withreattach_cdroms
=2
andremove_cdrom
=false
. Expected results: Two CD-ROMs remain. ✅ Build withreattach_cdroms
=2
andremove_cdrom
=true
. Expected results: Two CD-ROMs remainsreset_cdrom
is superceeded byreattach_cdroms
. ✅ Build withreattach_cdroms
=3
andremove_cdrom
=false
. Expected results: Three CD-ROMs remain. ✅ Build withreattach_cdroms
=3
andremove_cdrom
=true
. Expected results: Three CD-ROMs remainsreset_cdrom
is superceeded bykeep_cdrom
. ✅ Build withreattach_cdroms
=4
andremove_cdrom
=false
. Expected results: Four CD-ROMs remain. ✅ Build withreattach_cdroms
=4
andremove_cdrom
=true
. Expected results: Four CD-ROMs remainsreset_cdrom
is superceeded bykeep_cdrom
. ✅ Build withreattach_cdroms
=5
andremove_cdrom
=false
. Expected results: Caught inPrepare( )
.Reference
Closes #24 Supersedes #326