powershell

package
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2020 License: MPL-2.0 Imports: 23 Imported by: 44

Documentation

Overview

This package implements a provisioner for Packer that executes powershell scripts within the remote machine.

Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringToExecutionPolicyHook added in v1.4.2

func StringToExecutionPolicyHook(f reflect.Kind, t reflect.Kind, data interface{}) (interface{}, error)

Types

type Config

type Config struct {
	shell.Provisioner `mapstructure:",squash"`

	shell.ProvisionerRemoteSpecific `mapstructure:",squash"`

	// The remote path where the file containing the environment variables
	// will be uploaded to. This should be set to a writable file that is in a
	// pre-existing directory.
	RemoteEnvVarPath string `mapstructure:"remote_env_var_path"`

	// The command used to execute the elevated script. The '{{ .Path }}'
	// variable should be used to specify where the script goes, {{ .Vars }}
	// can be used to inject the environment_vars into the environment.
	ElevatedExecuteCommand string `mapstructure:"elevated_execute_command"`

	// Whether to clean scripts up after executing the provisioner.
	// Defaults to false. When true any script created by a non-elevated Powershell
	// provisioner will be removed from the remote machine. Elevated scripts,
	// along with the scheduled tasks, will always be removed regardless of the
	// value set for `skip_clean`.
	SkipClean bool `mapstructure:"skip_clean"`

	// The timeout for retrying to start the process. Until this timeout is
	// reached, if the provisioner can't start a process, it retries.  This
	// can be set high to allow for reboots.
	StartRetryTimeout time.Duration `mapstructure:"start_retry_timeout"`

	// This is used in the template generation to format environment variables
	// inside the `ElevatedExecuteCommand` template.
	ElevatedEnvVarFormat string `mapstructure:"elevated_env_var_format"`

	// Instructs the communicator to run the remote script as a Windows
	// scheduled task, effectively elevating the remote user by impersonating
	// a logged-in user
	ElevatedUser     string `mapstructure:"elevated_user"`
	ElevatedPassword string `mapstructure:"elevated_password"`

	ExecutionPolicy ExecutionPolicy `mapstructure:"execution_policy"`

	// If set, sets PowerShell's [PSDebug mode](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/set-psdebug?view=powershell-7)
	//  in order to make script debugging easier. For instance, setting the
	//    value to 1 results in adding this to the execute command:
	//
	//    “` powershell
	//    Set-PSDebug -Trace 1
	//    “`
	DebugMode int `mapstructure:"debug_mode"`
	// contains filtered or unexported fields
}

func (*Config) FlatMapstructure added in v1.4.5

func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatConfig. FlatConfig is an auto-generated flat version of Config. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type ExecutionPolicy added in v1.4.2

type ExecutionPolicy int

ExecutionPolicy setting to run the command(s). For the powershell provider the default has historically been to bypass.

const (
	ExecutionPolicyBypass ExecutionPolicy = iota
	ExecutionPolicyAllsigned
	ExecutionPolicyDefault
	ExecutionPolicyRemotesigned
	ExecutionPolicyRestricted
	ExecutionPolicyUndefined
	ExecutionPolicyUnrestricted
	ExecutionPolicyNone // not set
)

func ExecutionPolicyString added in v1.4.2

func ExecutionPolicyString(s string) (ExecutionPolicy, error)

ExecutionPolicyString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ExecutionPolicyValues added in v1.4.2

func ExecutionPolicyValues() []ExecutionPolicy

ExecutionPolicyValues returns all values of the enum

func (ExecutionPolicy) IsAExecutionPolicy added in v1.4.2

func (i ExecutionPolicy) IsAExecutionPolicy() bool

IsAExecutionPolicy returns "true" if the value is listed in the enum definition. "false" otherwise

func (ExecutionPolicy) String added in v1.4.2

func (i ExecutionPolicy) String() string

type FlatConfig added in v1.4.5

type FlatConfig struct {
	PackerBuildName        *string           `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"`
	PackerBuilderType      *string           `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"`
	PackerDebug            *bool             `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"`
	PackerForce            *bool             `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"`
	PackerOnError          *string           `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"`
	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"`
	Inline                 []string          `cty:"inline" hcl:"inline"`
	Script                 *string           `cty:"script" hcl:"script"`
	Scripts                []string          `cty:"scripts" hcl:"scripts"`
	ValidExitCodes         []int             `mapstructure:"valid_exit_codes" cty:"valid_exit_codes" hcl:"valid_exit_codes"`
	Vars                   []string          `mapstructure:"environment_vars" cty:"environment_vars" hcl:"environment_vars"`
	EnvVarFormat           *string           `mapstructure:"env_var_format" cty:"env_var_format" hcl:"env_var_format"`
	Binary                 *bool             `cty:"binary" hcl:"binary"`
	RemotePath             *string           `mapstructure:"remote_path" cty:"remote_path" hcl:"remote_path"`
	ExecuteCommand         *string           `mapstructure:"execute_command" cty:"execute_command" hcl:"execute_command"`
	RemoteEnvVarPath       *string           `mapstructure:"remote_env_var_path" cty:"remote_env_var_path" hcl:"remote_env_var_path"`
	ElevatedExecuteCommand *string           `mapstructure:"elevated_execute_command" cty:"elevated_execute_command" hcl:"elevated_execute_command"`
	SkipClean              *bool             `mapstructure:"skip_clean" cty:"skip_clean" hcl:"skip_clean"`
	StartRetryTimeout      *string           `mapstructure:"start_retry_timeout" cty:"start_retry_timeout" hcl:"start_retry_timeout"`
	ElevatedEnvVarFormat   *string           `mapstructure:"elevated_env_var_format" cty:"elevated_env_var_format" hcl:"elevated_env_var_format"`
	ElevatedUser           *string           `mapstructure:"elevated_user" cty:"elevated_user" hcl:"elevated_user"`
	ElevatedPassword       *string           `mapstructure:"elevated_password" cty:"elevated_password" hcl:"elevated_password"`
	ExecutionPolicy        *string           `mapstructure:"execution_policy" cty:"execution_policy" hcl:"execution_policy"`
	DebugMode              *int              `mapstructure:"debug_mode" cty:"debug_mode" hcl:"debug_mode"`
}

FlatConfig is an auto-generated flat version of Config. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatConfig) HCL2Spec added in v1.4.5

func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a Config. This spec is used by HCL to read the fields of Config. The decoded values from this spec will then be applied to a FlatConfig.

type Provisioner

type Provisioner struct {
	// contains filtered or unexported fields
}

func (*Provisioner) Communicator added in v1.3.4

func (p *Provisioner) Communicator() packer.Communicator

func (*Provisioner) ConfigSpec added in v1.5.0

func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec

func (*Provisioner) ElevatedPassword added in v1.3.4

func (p *Provisioner) ElevatedPassword() string

func (*Provisioner) ElevatedUser added in v1.3.4

func (p *Provisioner) ElevatedUser() string

func (*Provisioner) Prepare

func (p *Provisioner) Prepare(raws ...interface{}) error

func (*Provisioner) Provision

func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData map[string]interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL