From 4692cdd55ca5f16729f50a376d93f77fee577456 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Fri, 26 Jun 2020 14:50:39 +0200 Subject: [PATCH] builder/hyperone: Allow skip chroot device discovery --- builder/hyperone/config.go | 1 + builder/hyperone/config.hcl2spec.go | 2 ++ builder/hyperone/step_prepare_device.go | 7 +++++++ website/pages/docs/builders/hyperone.mdx | 3 +++ .../partials/builder/hyperone/Config-not-required.mdx | 1 + 5 files changed, 14 insertions(+) diff --git a/builder/hyperone/config.go b/builder/hyperone/config.go index 01f090cda..8f9b32aab 100644 --- a/builder/hyperone/config.go +++ b/builder/hyperone/config.go @@ -100,6 +100,7 @@ type Config struct { // Can be useful when using custom api_url. Defaults to public. PublicNetAdpService string `mapstructure:"public_netadp_service" required:"false"` + ChrootDevice string `mapstructure:"chroot_device"` ChrootDisk bool `mapstructure:"chroot_disk"` ChrootDiskSize float32 `mapstructure:"chroot_disk_size"` ChrootDiskType string `mapstructure:"chroot_disk_type"` diff --git a/builder/hyperone/config.hcl2spec.go b/builder/hyperone/config.hcl2spec.go index 8f1ca2d6a..6f6587084 100644 --- a/builder/hyperone/config.hcl2spec.go +++ b/builder/hyperone/config.hcl2spec.go @@ -83,6 +83,7 @@ type FlatConfig struct { PrivateIP *string `mapstructure:"private_ip" required:"false" cty:"private_ip" hcl:"private_ip"` PublicIP *string `mapstructure:"public_ip" required:"false" cty:"public_ip" hcl:"public_ip"` PublicNetAdpService *string `mapstructure:"public_netadp_service" required:"false" cty:"public_netadp_service" hcl:"public_netadp_service"` + ChrootDevice *string `mapstructure:"chroot_device" cty:"chroot_device" hcl:"chroot_device"` ChrootDisk *bool `mapstructure:"chroot_disk" cty:"chroot_disk" hcl:"chroot_disk"` ChrootDiskSize *float32 `mapstructure:"chroot_disk_size" cty:"chroot_disk_size" hcl:"chroot_disk_size"` ChrootDiskType *string `mapstructure:"chroot_disk_type" cty:"chroot_disk_type" hcl:"chroot_disk_type"` @@ -183,6 +184,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "private_ip": &hcldec.AttrSpec{Name: "private_ip", Type: cty.String, Required: false}, "public_ip": &hcldec.AttrSpec{Name: "public_ip", Type: cty.String, Required: false}, "public_netadp_service": &hcldec.AttrSpec{Name: "public_netadp_service", Type: cty.String, Required: false}, + "chroot_device": &hcldec.AttrSpec{Name: "chroot_device", Type: cty.String, Required: false}, "chroot_disk": &hcldec.AttrSpec{Name: "chroot_disk", Type: cty.Bool, Required: false}, "chroot_disk_size": &hcldec.AttrSpec{Name: "chroot_disk_size", Type: cty.Number, Required: false}, "chroot_disk_type": &hcldec.AttrSpec{Name: "chroot_disk_type", Type: cty.String, Required: false}, diff --git a/builder/hyperone/step_prepare_device.go b/builder/hyperone/step_prepare_device.go index 80cb9c617..c0d42852c 100644 --- a/builder/hyperone/step_prepare_device.go +++ b/builder/hyperone/step_prepare_device.go @@ -17,6 +17,13 @@ type stepPrepareDevice struct{} func (s *stepPrepareDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) + config := state.Get("config").(*Config) + + if config.ChrootDevice != "" { + state.Put("device", config.ChrootDevice) + return multistep.ActionContinue + } + controllerNumber := state.Get("chroot_controller_number").(string) controllerLocation := state.Get("chroot_controller_location").(int) diff --git a/website/pages/docs/builders/hyperone.mdx b/website/pages/docs/builders/hyperone.mdx index 34c1c742d..b522a9355 100644 --- a/website/pages/docs/builders/hyperone.mdx +++ b/website/pages/docs/builders/hyperone.mdx @@ -181,6 +181,9 @@ builder. that will be copied into the chroot environment before provisioning. Defaults to `/etc/resolv.conf` so that DNS lookups work. +- `chroot_device` (string) - The path of chroot device. Defaults an attempt is + made to identify it based on the attach location. + - `chroot_disk_size` (float) - The size of the chroot disk in GiB. Defaults to `disk_size`. diff --git a/website/pages/partials/builder/hyperone/Config-not-required.mdx b/website/pages/partials/builder/hyperone/Config-not-required.mdx index 691221571..54cb7277b 100644 --- a/website/pages/partials/builder/hyperone/Config-not-required.mdx +++ b/website/pages/partials/builder/hyperone/Config-not-required.mdx @@ -49,6 +49,7 @@ - `public_netadp_service` (string) - Custom service of public network adapter. Can be useful when using custom api_url. Defaults to public. +- `chroot_device` (string) - Chroot Device - `chroot_disk` (bool) - Chroot Disk - `chroot_disk_size` (float32) - Chroot Disk Size - `chroot_disk_type` (string) - Chroot Disk Type