From af48008224b51ad5f27af6dd52ac50f253666c2d Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 23 Mar 2021 12:31:13 +0100 Subject: [PATCH] Add http_content func to serve variables from HTTP @ preseed (#10801) This imports hashicorp/packer-plugin-sdk#43 * code generate things * update docs * update guides * update examples We want to add a new guide. --- builder/cloudstack/builder.go | 7 +------ builder/cloudstack/config.hcl2spec.go | 2 ++ website/content/docs/builders/cloudstack.mdx | 15 --------------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/builder/cloudstack/builder.go b/builder/cloudstack/builder.go index 53d71a9..08f9ebe 100644 --- a/builder/cloudstack/builder.go +++ b/builder/cloudstack/builder.go @@ -60,12 +60,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) // Build the steps. steps := []multistep.Step{ &stepPrepareConfig{}, - &commonsteps.StepHTTPServer{ - HTTPDir: b.config.HTTPDir, - HTTPPortMin: b.config.HTTPPortMin, - HTTPPortMax: b.config.HTTPPortMax, - HTTPAddress: b.config.HTTPAddress, - }, + commonsteps.HTTPServerFromHTTPConfig(&b.config.HTTPConfig), &stepKeypair{ Debug: b.config.PackerDebug, Comm: &b.config.Comm, diff --git a/builder/cloudstack/config.hcl2spec.go b/builder/cloudstack/config.hcl2spec.go index 171a7df..638223c 100644 --- a/builder/cloudstack/config.hcl2spec.go +++ b/builder/cloudstack/config.hcl2spec.go @@ -19,6 +19,7 @@ type FlatConfig struct { PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` HTTPDir *string `mapstructure:"http_directory" cty:"http_directory" hcl:"http_directory"` + HTTPContent map[string]string `mapstructure:"http_content" cty:"http_content" hcl:"http_content"` HTTPPortMin *int `mapstructure:"http_port_min" cty:"http_port_min" hcl:"http_port_min"` HTTPPortMax *int `mapstructure:"http_port_max" cty:"http_port_max" hcl:"http_port_max"` HTTPAddress *string `mapstructure:"http_bind_address" cty:"http_bind_address" hcl:"http_bind_address"` @@ -135,6 +136,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, "http_directory": &hcldec.AttrSpec{Name: "http_directory", Type: cty.String, Required: false}, + "http_content": &hcldec.AttrSpec{Name: "http_content", Type: cty.Map(cty.String), Required: false}, "http_port_min": &hcldec.AttrSpec{Name: "http_port_min", Type: cty.Number, Required: false}, "http_port_max": &hcldec.AttrSpec{Name: "http_port_max", Type: cty.Number, Required: false}, "http_bind_address": &hcldec.AttrSpec{Name: "http_bind_address", Type: cty.String, Required: false}, diff --git a/website/content/docs/builders/cloudstack.mdx b/website/content/docs/builders/cloudstack.mdx index 149370e..55e0c74 100644 --- a/website/content/docs/builders/cloudstack.mdx +++ b/website/content/docs/builders/cloudstack.mdx @@ -89,25 +89,10 @@ builder. - `expunge` (boolean) - Set to `true` to expunge the instance when it is destroyed. Defaults to `false`. -- `http_directory` (string) - Path to a directory to serve using an HTTP - server. The files in this directory will be available over HTTP that will - be requestable from the virtual machine. This is useful for hosting - kickstart files and so on. By default this is "", which means no HTTP - server will be started. The address and port of the HTTP server will be - available as variables in `user_data`. This is covered in more detail - below. - - `http_get_only` (boolean) - Some cloud providers only allow HTTP GET calls to their CloudStack API. If using such a provider, you need to set this to `true` in order for the provider to only make GET calls and no POST calls. -- `http_port_min` and `http_port_max` (number) - These are the minimum and - maximum port to use for the HTTP server started to serve the - `http_directory`. Because Packer often runs in parallel, Packer will choose - a randomly available port in this range to run the HTTP server. If you want - to force the HTTP server to be on one port, make this minimum and maximum - port the same. By default the values are 8000 and 9000, respectively. - - `hypervisor` (string) - The target hypervisor (e.g. `XenServer`, `KVM`) for the new template. This option is required when using `source_iso`.