From 171c2a9a07b6dafa0cc1380f76e8497efbe43a9d Mon Sep 17 00:00:00 2001 From: allinwait Date: Thu, 12 Sep 2019 12:25:22 +0000 Subject: [PATCH] add the floppy label option --- builder/hyperv/iso/builder.go | 1 + builder/hyperv/vmcx/builder.go | 1 + builder/parallels/iso/builder.go | 1 + builder/parallels/pvm/builder.go | 1 + builder/qemu/builder.go | 1 + builder/virtualbox/iso/builder.go | 1 + builder/virtualbox/ovf/builder.go | 1 + builder/vmware/iso/builder.go | 1 + builder/vmware/vmx/builder.go | 1 + common/floppy_config.go | 1 + common/step_create_floppy.go | 11 +++++++++-- website/source/docs/builders/hyperv-iso.html.md.erb | 5 +++++ website/source/docs/builders/hyperv-vmcx.html.md.erb | 5 +++++ .../source/docs/builders/parallels-iso.html.md.erb | 5 +++++ .../source/docs/builders/parallels-pvm.html.md.erb | 5 +++++ website/source/docs/builders/qemu.html.md.erb | 5 +++++ .../source/docs/builders/virtualbox-iso.html.md.erb | 5 +++++ .../source/docs/builders/virtualbox-ovf.html.md.erb | 5 +++++ website/source/docs/builders/vmware-iso.html.md.erb | 5 +++++ website/source/docs/builders/vmware-vmx.html.md.erb | 5 +++++ 20 files changed, 64 insertions(+), 2 deletions(-) diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index e97c50162..673ac554b 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -393,6 +393,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, + Label: b.config.FloppyConfig.FloppyLabel, }, &common.StepHTTPServer{ HTTPDir: b.config.HTTPDir, diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index 94dc77644..8c98ede56 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -432,6 +432,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepCreateFloppy{ Files: b.config.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, + Label: b.config.FloppyConfig.FloppyLabel, }, &common.StepHTTPServer{ HTTPDir: b.config.HTTPDir, diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index 688d063fc..ecc4e5a43 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -169,6 +169,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, + Label: b.config.FloppyConfig.FloppyLabel, }, &common.StepHTTPServer{ HTTPDir: b.config.HTTPDir, diff --git a/builder/parallels/pvm/builder.go b/builder/parallels/pvm/builder.go index d62415a3d..a199650d1 100644 --- a/builder/parallels/pvm/builder.go +++ b/builder/parallels/pvm/builder.go @@ -61,6 +61,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, + Label: b.config.FloppyConfig.FloppyLabel, }, &StepImport{ Name: b.config.VMName, diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index b3d826e8d..5fbf056e9 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -413,6 +413,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, + Label: b.config.FloppyConfig.FloppyLabel, }, new(stepCreateDisk), new(stepCopyDisk), diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index 5a94a216e..1df3b8ba2 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -223,6 +223,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, + Label: b.config.FloppyConfig.FloppyLabel, }, &common.StepHTTPServer{ HTTPDir: b.config.HTTPDir, diff --git a/builder/virtualbox/ovf/builder.go b/builder/virtualbox/ovf/builder.go index aa3546c7b..8984880b5 100644 --- a/builder/virtualbox/ovf/builder.go +++ b/builder/virtualbox/ovf/builder.go @@ -57,6 +57,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, + Label: b.config.FloppyConfig.FloppyLabel, }, &common.StepHTTPServer{ HTTPDir: b.config.HTTPDir, diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index fb4c4967b..59e63ef2b 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -86,6 +86,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, + Label: b.config.FloppyConfig.FloppyLabel, }, &stepRemoteUpload{ Key: "floppy_path", diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index fd4cfa1b9..afddce786 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -82,6 +82,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, + Label: b.config.FloppyConfig.FloppyLabel, }, &StepCloneVMX{ OutputDir: b.config.OutputDir, diff --git a/common/floppy_config.go b/common/floppy_config.go index b1338cbcb..afa1be4dd 100644 --- a/common/floppy_config.go +++ b/common/floppy_config.go @@ -12,6 +12,7 @@ import ( type FloppyConfig struct { FloppyFiles []string `mapstructure:"floppy_files"` FloppyDirectories []string `mapstructure:"floppy_dirs"` + FloppyLabel string `mapstructure:"floppy_label"` } func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error { diff --git a/common/step_create_floppy.go b/common/step_create_floppy.go index cb2278372..9cd78dba8 100644 --- a/common/step_create_floppy.go +++ b/common/step_create_floppy.go @@ -21,6 +21,7 @@ import ( type StepCreateFloppy struct { Files []string Directories []string + Label string floppyPath string @@ -33,6 +34,12 @@ func (s *StepCreateFloppy) Run(ctx context.Context, state multistep.StateBag) mu return multistep.ActionContinue } + if s.Label == "" { + s.Label = "packer" + } else { + log.Println("Floppy label is set to %s", s.Label) + } + s.FilesAdded = make(map[string]bool) ui := state.Get("ui").(packer.Ui) @@ -70,8 +77,8 @@ func (s *StepCreateFloppy) Run(ctx context.Context, state multistep.StateBag) mu log.Println("Formatting the block device with a FAT filesystem...") formatConfig := &fat.SuperFloppyConfig{ FATType: fat.FAT12, - Label: "packer", - OEMName: "packer", + Label: s.Label, + OEMName: s.Label, } if err := fat.FormatSuperFloppy(device, formatConfig); err != nil { state.Put("error", fmt.Errorf("Error creating floppy: %s", err)) diff --git a/website/source/docs/builders/hyperv-iso.html.md.erb b/website/source/docs/builders/hyperv-iso.html.md.erb index 716285d5c..9545b44f1 100644 --- a/website/source/docs/builders/hyperv-iso.html.md.erb +++ b/website/source/docs/builders/hyperv-iso.html.md.erb @@ -134,6 +134,11 @@ builder. (`*`, `?`, and `[]`) are allowed. Directory names are also allowed, which will add all the files found in the directory to the floppy. +- `floppy_label` (string) - The label to use for the floppy disk that + is attached when the VM is booted. This is most useful for cloud-init, + Kickstart or other early initialization tools, which can benefit from labelled floppy disks. + By default, the floppy label will be 'packer'. + - `generation` (number) - The Hyper-V generation for the virtual machine. By default, this is 1. Generation 2 Hyper-V virtual machines do not support floppy drives. In this scenario use `secondary_iso_images` instead. Hard diff --git a/website/source/docs/builders/hyperv-vmcx.html.md.erb b/website/source/docs/builders/hyperv-vmcx.html.md.erb index 726d0a2c1..894226398 100644 --- a/website/source/docs/builders/hyperv-vmcx.html.md.erb +++ b/website/source/docs/builders/hyperv-vmcx.html.md.erb @@ -171,6 +171,11 @@ builder. (`*`, `?`, and `[]`) are allowed. Directory names are also allowed, which will add all the files found in the directory to the floppy. +- `floppy_label` (string) - The label to use for the floppy disk that + is attached when the VM is booted. This is most useful for cloud-init, + Kickstart or other early initialization tools, which can benefit from labelled floppy disks. + By default, the floppy label will be 'packer'. + - `guest_additions_mode` (string) - If set to `attach` then attach and mount the ISO image specified in `guest_additions_path`. If set to `none` then guest additions are not attached and mounted; This is the diff --git a/website/source/docs/builders/parallels-iso.html.md.erb b/website/source/docs/builders/parallels-iso.html.md.erb index 5f7e69f1c..bb17e0047 100644 --- a/website/source/docs/builders/parallels-iso.html.md.erb +++ b/website/source/docs/builders/parallels-iso.html.md.erb @@ -111,6 +111,11 @@ builder. your floppy disk includes drivers or if you just want to organize it's contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed. +- `floppy_label` (string) - The label to use for the floppy disk that + is attached when the VM is booted. This is most useful for cloud-init, + Kickstart or other early initialization tools, which can benefit from labelled floppy disks. + By default, the floppy label will be 'packer'. + - `guest_os_type` (string) - The guest OS type being installed. By default this is "other", but you can get *dramatic* performance improvements by setting this to the proper value. To view all available values for this run diff --git a/website/source/docs/builders/parallels-pvm.html.md.erb b/website/source/docs/builders/parallels-pvm.html.md.erb index 9cc9ab14a..6a4185b26 100644 --- a/website/source/docs/builders/parallels-pvm.html.md.erb +++ b/website/source/docs/builders/parallels-pvm.html.md.erb @@ -95,6 +95,11 @@ builder. your floppy disk includes drivers or if you just want to organize it's contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed. +- `floppy_label` (string) - The label to use for the floppy disk that + is attached when the VM is booted. This is most useful for cloud-init, + Kickstart or other early initialization tools, which can benefit from labelled floppy disks. + By default, the floppy label will be 'packer'. + - `output_directory` (string) - This is the path to the directory where the resulting virtual machine will be created. This may be relative or absolute. If relative, the path is relative to the working directory when `packer` diff --git a/website/source/docs/builders/qemu.html.md.erb b/website/source/docs/builders/qemu.html.md.erb index fe0a9143e..7123dd334 100644 --- a/website/source/docs/builders/qemu.html.md.erb +++ b/website/source/docs/builders/qemu.html.md.erb @@ -209,6 +209,11 @@ Linux server and have not enabled X11 forwarding (`ssh -X`). listed files must not exceed 1.44 MB. The supported ways to move large files into the OS are using `http_directory` or [the file provisioner](https://www.packer.io/docs/provisioners/file.html). +- `floppy_label` (string) - The label to use for the floppy disk that + is attached when the VM is booted. This is most useful for cloud-init, + Kickstart or other early initialization tools, which can benefit from labelled floppy disks. + By default, the floppy label will be 'packer'. + - `format` (string) - Either `qcow2` or `raw`, this specifies the output format of the virtual machine image. This defaults to `qcow2`. diff --git a/website/source/docs/builders/virtualbox-iso.html.md.erb b/website/source/docs/builders/virtualbox-iso.html.md.erb index 6a7906474..a5703dfe7 100644 --- a/website/source/docs/builders/virtualbox-iso.html.md.erb +++ b/website/source/docs/builders/virtualbox-iso.html.md.erb @@ -136,6 +136,11 @@ builder. and \[\]) are allowed. Directory names are also allowed, which will add all the files found in the directory to the floppy. +- `floppy_label` (string) - The label to use for the floppy disk that + is attached when the VM is booted. This is most useful for cloud-init, + Kickstart or other early initialization tools, which can benefit from labelled floppy disks. + By default, the floppy label will be 'packer'. + - `format` (string) - Either `ovf` or `ova`, this specifies the output format of the exported virtual machine. This defaults to `ovf`. diff --git a/website/source/docs/builders/virtualbox-ovf.html.md.erb b/website/source/docs/builders/virtualbox-ovf.html.md.erb index cc47fbbcd..7d686d340 100644 --- a/website/source/docs/builders/virtualbox-ovf.html.md.erb +++ b/website/source/docs/builders/virtualbox-ovf.html.md.erb @@ -153,6 +153,11 @@ builder. and \[\]) are allowed. Directory names are also allowed, which will add all the files found in the directory to the floppy. +- `floppy_label` (string) - The label to use for the floppy disk that + is attached when the VM is booted. This is most useful for cloud-init, + Kickstart or other early initialization tools, which can benefit from labelled floppy disks. + By default, the floppy label will be 'packer'. + - `format` (string) - Either `ovf` or `ova`, this specifies the output format of the exported virtual machine. This defaults to `ovf`. diff --git a/website/source/docs/builders/vmware-iso.html.md.erb b/website/source/docs/builders/vmware-iso.html.md.erb index 4c67d26be..71dfec1c6 100644 --- a/website/source/docs/builders/vmware-iso.html.md.erb +++ b/website/source/docs/builders/vmware-iso.html.md.erb @@ -160,6 +160,11 @@ builder. and \[\]) are allowed. Directory names are also allowed, which will add all the files found in the directory to the floppy. +- `floppy_label` (string) - The label to use for the floppy disk that + is attached when the VM is booted. This is most useful for cloud-init, + Kickstart or other early initialization tools, which can benefit from labelled floppy disks. + By default, the floppy label will be 'packer'. + - `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this is `/Applications/VMware Fusion.app` but this setting allows you to customize this. diff --git a/website/source/docs/builders/vmware-vmx.html.md.erb b/website/source/docs/builders/vmware-vmx.html.md.erb index 362a0bcc8..98d80955a 100644 --- a/website/source/docs/builders/vmware-vmx.html.md.erb +++ b/website/source/docs/builders/vmware-vmx.html.md.erb @@ -102,6 +102,11 @@ builder. and \[\]) are allowed. Directory names are also allowed, which will add all the files found in the directory to the floppy. +- `floppy_label` (string) - The label to use for the floppy disk that + is attached when the VM is booted. This is most useful for cloud-init, + Kickstart or other early initialization tools, which can benefit from labelled floppy disks. + By default, the floppy label will be 'packer'. + - `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this is `/Applications/VMware Fusion.app` but this setting allows you to customize this.