floppy_label Parameter for vsphere-iso Builder (#9187)

Add ability to specify `floppy_label` parameter for `vsphere-iso`
builder, which would be especially beneficial when someone wants to pass
information to cloud-init via floppy disk images.

Signed-off-by: Ryo Tagami <rtagami@airstrip.jp>
This commit is contained in:
Ryo Tagami 2020-05-08 23:13:54 +09:00 committed by GitHub
parent d807e81adb
commit fdc73376ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 0 deletions

View File

@ -81,6 +81,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
&packerCommon.StepCreateFloppy{ &packerCommon.StepCreateFloppy{
Files: b.config.FloppyFiles, Files: b.config.FloppyFiles,
Directories: b.config.FloppyDirectories, Directories: b.config.FloppyDirectories,
Label: b.config.FloppyLabel,
}, },
&StepAddFloppy{ &StepAddFloppy{
Config: &b.config.FloppyConfig, Config: &b.config.FloppyConfig,

View File

@ -70,6 +70,7 @@ type FlatConfig struct {
FloppyIMGPath *string `mapstructure:"floppy_img_path" cty:"floppy_img_path"` FloppyIMGPath *string `mapstructure:"floppy_img_path" cty:"floppy_img_path"`
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"` FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"` FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
FloppyLabel *string `mapstructure:"floppy_label" cty:"floppy_label"`
BootOrder *string `mapstructure:"boot_order" cty:"boot_order"` BootOrder *string `mapstructure:"boot_order" cty:"boot_order"`
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"` BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"` BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
@ -198,6 +199,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"floppy_img_path": &hcldec.AttrSpec{Name: "floppy_img_path", Type: cty.String, Required: false}, "floppy_img_path": &hcldec.AttrSpec{Name: "floppy_img_path", Type: cty.String, Required: false},
"floppy_files": &hcldec.AttrSpec{Name: "floppy_files", Type: cty.List(cty.String), Required: false}, "floppy_files": &hcldec.AttrSpec{Name: "floppy_files", Type: cty.List(cty.String), Required: false},
"floppy_dirs": &hcldec.AttrSpec{Name: "floppy_dirs", Type: cty.List(cty.String), Required: false}, "floppy_dirs": &hcldec.AttrSpec{Name: "floppy_dirs", Type: cty.List(cty.String), Required: false},
"floppy_label": &hcldec.AttrSpec{Name: "floppy_label", Type: cty.String, Required: false},
"boot_order": &hcldec.AttrSpec{Name: "boot_order", Type: cty.String, Required: false}, "boot_order": &hcldec.AttrSpec{Name: "boot_order", Type: cty.String, Required: false},
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false}, "boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false}, "boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},

View File

@ -21,6 +21,11 @@ type FloppyConfig struct {
FloppyFiles []string `mapstructure:"floppy_files"` FloppyFiles []string `mapstructure:"floppy_files"`
// List of directories to copy files from. // List of directories to copy files from.
FloppyDirectories []string `mapstructure:"floppy_dirs"` FloppyDirectories []string `mapstructure:"floppy_dirs"`
// 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'.
FloppyLabel string `mapstructure:"floppy_label"`
} }
type StepAddFloppy struct { type StepAddFloppy struct {

View File

@ -12,6 +12,7 @@ type FlatFloppyConfig struct {
FloppyIMGPath *string `mapstructure:"floppy_img_path" cty:"floppy_img_path"` FloppyIMGPath *string `mapstructure:"floppy_img_path" cty:"floppy_img_path"`
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"` FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"` FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
FloppyLabel *string `mapstructure:"floppy_label" cty:"floppy_label"`
} }
// FlatMapstructure returns a new FlatFloppyConfig. // FlatMapstructure returns a new FlatFloppyConfig.
@ -29,6 +30,7 @@ func (*FlatFloppyConfig) HCL2Spec() map[string]hcldec.Spec {
"floppy_img_path": &hcldec.AttrSpec{Name: "floppy_img_path", Type: cty.String, Required: false}, "floppy_img_path": &hcldec.AttrSpec{Name: "floppy_img_path", Type: cty.String, Required: false},
"floppy_files": &hcldec.AttrSpec{Name: "floppy_files", Type: cty.List(cty.String), Required: false}, "floppy_files": &hcldec.AttrSpec{Name: "floppy_files", Type: cty.List(cty.String), Required: false},
"floppy_dirs": &hcldec.AttrSpec{Name: "floppy_dirs", Type: cty.List(cty.String), Required: false}, "floppy_dirs": &hcldec.AttrSpec{Name: "floppy_dirs", Type: cty.List(cty.String), Required: false},
"floppy_label": &hcldec.AttrSpec{Name: "floppy_label", Type: cty.String, Required: false},
} }
return s return s
} }

View File

@ -7,4 +7,9 @@
make Debian preseed or RHEL kickstart files available to the VM. make Debian preseed or RHEL kickstart files available to the VM.
- `floppy_dirs` ([]string) - List of directories to copy files from. - `floppy_dirs` ([]string) - List of directories to copy files from.
- `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'.