Documentation ¶
Overview ¶
Code generated by "mapstructure-to-hcl2 -type Config,SSH,WinRM"; DO NOT EDIT.
Index ¶
- Constants
- func CommHost(host string, statebagKey string) func(multistep.StateBag) (string, error)
- func TestPEM(t *testing.T) string
- type Config
- func (*Config) FlatMapstructure() interface{ ... }
- func (c *Config) Host() string
- func (c *Config) Password() string
- func (c *Config) Port() int
- func (c *Config) Prepare(ctx *interpolate.Context) []error
- func (c *Config) ReadSSHPrivateKeyFile() ([]byte, error)
- func (c *Config) SSHConfigFunc() func(multistep.StateBag) (*ssh.ClientConfig, error)
- func (c *Config) User() string
- type FlatConfig
- type FlatSSH
- type FlatWinRM
- type SSH
- type SSHInterface
- type StepConnect
- type StepConnectSSH
- type StepConnectWinRM
- type WinRM
- type WinRMConfig
Constants ¶
const TestPEMContents = `` /* 1680-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Packer currently supports three kinds of communicators: // // - `none` - No communicator will be used. If this is set, most // provisioners also can't be used. // // - `ssh` - An SSH connection will be established to the machine. This // is usually the default. // // - `winrm` - A WinRM connection will be established. // // In addition to the above, some builders have custom communicators they // can use. For example, the Docker builder has a "docker" communicator // that uses `docker exec` and `docker cp` to execute scripts and copy // files. Type string `mapstructure:"communicator"` // We recommend that you enable SSH or WinRM as the very last step in your // guest's bootstrap script, but sometimes you may have a race condition where // you need Packer to wait before attempting to connect to your guest. // // If you end up in this situation, you can use the template option // `pause_before_connecting`. By default, there is no pause. For example: // // “`json // { // "communicator": "ssh", // "ssh_username": "myuser", // "pause_before_connecting": "10m" // } // “` // // In this example, Packer will check whether it can connect, as normal. But once // a connection attempt is successful, it will disconnect and then wait 10 minutes // before connecting to the guest and beginning provisioning. PauseBeforeConnect time.Duration `mapstructure:"pause_before_connecting"` SSH `mapstructure:",squash"` WinRM `mapstructure:",squash"` }
Config is the common configuration that communicators allow within a builder.
func (*Config) FlatMapstructure ¶ added in v1.4.5
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.
func (*Config) Host ¶ added in v0.11.0
Host returns the port that will be used for access based on config.
func (*Config) Password ¶ added in v0.11.0
Password returns the port that will be used for access based on config.
func (*Config) ReadSSHPrivateKeyFile ¶ added in v1.3.3
ReadSSHPrivateKeyFile returns the SSH private key bytes
func (*Config) SSHConfigFunc ¶ added in v1.3.0
SSHConfigFunc returns a function that can be used for the SSH communicator config for connecting to the instance created over SSH using the private key or password.
type FlatConfig ¶ added in v1.4.5
type FlatConfig struct { Type *string `mapstructure:"communicator" cty:"communicator"` PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"` SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"` SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"` SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"` SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"` SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"` SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"` SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"` SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"` SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"` SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"` SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"` SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"` SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"` SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"` SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"` SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"` SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"` SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"` SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"` SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"` SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"` SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"` SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"` SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"` SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"` SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"` SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"` SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"` SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"` SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"` WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"` WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"` WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"` WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"` WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"` WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"` WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"` WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"` }
FlatConfig is an auto-generated flat version of Config. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatSSH ¶ added in v1.4.5
type FlatSSH struct { SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"` SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"` SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"` SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"` SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"` SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"` SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"` SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"` SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"` SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"` SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"` SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"` SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"` SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"` SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"` SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"` SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"` SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"` SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"` SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"` SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"` SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"` SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"` SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"` SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"` SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"` SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"` SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"` SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"` SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"` }
FlatSSH is an auto-generated flat version of SSH. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatWinRM ¶ added in v1.4.5
type FlatWinRM struct { WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"` WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"` WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"` WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"` WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"` WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"` WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"` WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"` }
FlatWinRM is an auto-generated flat version of WinRM. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type SSH ¶ added in v1.4.4
type SSH struct { // The address to SSH to. This usually is automatically configured by the // builder. SSHHost string `mapstructure:"ssh_host"` // The port to connect to SSH. This defaults to `22`. SSHPort int `mapstructure:"ssh_port"` // The username to connect to SSH with. Required if using SSH. SSHUsername string `mapstructure:"ssh_username"` // A plaintext password to use to authenticate with SSH. SSHPassword string `mapstructure:"ssh_password"` // If specified, this is the key that will be used for SSH with the // machine. The key must match a key pair name loaded up into Amazon EC2. // By default, this is blank, and Packer will generate a temporary keypair // unless [`ssh_password`](../templates/communicator.html#ssh_password) is // used. // [`ssh_private_key_file`](../templates/communicator.html#ssh_private_key_file) // or `ssh_agent_auth` must be specified when `ssh_keypair_name` is // utilized. SSHKeyPairName string `mapstructure:"ssh_keypair_name"` // The name of the temporary key pair to generate. By default, Packer // generates a name that looks like `packer_<UUID>`, where <UUID> is // a 36 character unique identifier. SSHTemporaryKeyPairName string `mapstructure:"temporary_key_pair_name"` // If true, Packer will attempt to remove its temporary key from // `~/.ssh/authorized_keys` and `/root/.ssh/authorized_keys`. This is a // mostly cosmetic option, since Packer will delete the temporary private // key from the host system regardless of whether this is set to true // (unless the user has set the `-debug` flag). Defaults to "false"; // currently only works on guests with `sed` installed. SSHClearAuthorizedKeys bool `mapstructure:"ssh_clear_authorized_keys"` // Path to a PEM encoded private key file to use to authenticate with SSH. // The `~` can be used in path and will be expanded to the home directory // of current user. SSHPrivateKeyFile string `mapstructure:"ssh_private_key_file"` // If `true`, a PTY will be requested for the SSH connection. This defaults // to `false`. SSHPty bool `mapstructure:"ssh_pty"` // The time to wait for SSH to become available. Packer uses this to // determine when the machine has booted so this is usually quite long. // Example value: `10m`. SSHTimeout time.Duration `mapstructure:"ssh_timeout"` // If true, the local SSH agent will be used to authenticate connections to // the source instance. No temporary keypair will be created, and the // values of `ssh_password` and `ssh_private_key_file` will be ignored. To // use this option with a key pair already configured in the source AMI, // leave the `ssh_keypair_name` blank. To associate an existing key pair in // AWS with the source instance, set the `ssh_keypair_name` field to the // name of the key pair. The environment variable `SSH_AUTH_SOCK` must be // set for this option to work properly. SSHAgentAuth bool `mapstructure:"ssh_agent_auth"` // If true, SSH agent forwarding will be disabled. Defaults to `false`. SSHDisableAgentForwarding bool `mapstructure:"ssh_disable_agent_forwarding"` // The number of handshakes to attempt with SSH once it can connect. This // defaults to `10`. SSHHandshakeAttempts int `mapstructure:"ssh_handshake_attempts"` // A bastion host to use for the actual SSH connection. SSHBastionHost string `mapstructure:"ssh_bastion_host"` // The port of the bastion host. Defaults to `22`. SSHBastionPort int `mapstructure:"ssh_bastion_port"` // If `true`, the local SSH agent will be used to authenticate with the // bastion host. Defaults to `false`. SSHBastionAgentAuth bool `mapstructure:"ssh_bastion_agent_auth"` // The username to connect to the bastion host. SSHBastionUsername string `mapstructure:"ssh_bastion_username"` // The password to use to authenticate with the bastion host. SSHBastionPassword string `mapstructure:"ssh_bastion_password"` // Path to a PEM encoded private key file to use to authenticate with the // bastion host. The `~` can be used in path and will be expanded to the // home directory of current user. SSHBastionPrivateKeyFile string `mapstructure:"ssh_bastion_private_key_file"` // `scp` or `sftp` - How to transfer files, Secure copy (default) or SSH // File Transfer Protocol. SSHFileTransferMethod string `mapstructure:"ssh_file_transfer_method"` // A SOCKS proxy host to use for SSH connection SSHProxyHost string `mapstructure:"ssh_proxy_host"` // A port of the SOCKS proxy. Defaults to `1080`. SSHProxyPort int `mapstructure:"ssh_proxy_port"` // The optional username to authenticate with the proxy server. SSHProxyUsername string `mapstructure:"ssh_proxy_username"` // The optional password to use to authenticate with the proxy server. SSHProxyPassword string `mapstructure:"ssh_proxy_password"` // How often to send "keep alive" messages to the server. Set to a negative // value (`-1s`) to disable. Example value: `10s`. Defaults to `5s`. SSHKeepAliveInterval time.Duration `mapstructure:"ssh_keep_alive_interval"` // The amount of time to wait for a remote command to end. This might be // useful if, for example, packer hangs on a connection after a reboot. // Example: `5m`. Disabled by default. SSHReadWriteTimeout time.Duration `mapstructure:"ssh_read_write_timeout"` // SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels"` // SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels"` // SSH Internals SSHPublicKey []byte `mapstructure:"ssh_public_key"` SSHPrivateKey []byte `mapstructure:"ssh_private_key"` }
func (*SSH) ConfigSpec ¶ added in v1.5.0
func (c *SSH) ConfigSpec() hcldec.ObjectSpec
type SSHInterface ¶ added in v1.4.4
type SSHInterface struct { // One of `public_ip`, `private_ip`, `public_dns`, or `private_dns`. If // set, either the public IP address, private IP address, public DNS name // or private DNS name will used as the host for SSH. The default behaviour // if inside a VPC is to use the public IP address if available, otherwise // the private IP address will be used. If not in a VPC the public DNS name // will be used. Also works for WinRM. // // Where Packer is configured for an outbound proxy but WinRM traffic // should be direct, `ssh_interface` must be set to `private_dns` and // `<region>.compute.internal` included in the `NO_PROXY` environment // variable. SSHInterface string `mapstructure:"ssh_interface"` // The IP version to use for SSH connections, valid values are `4` and `6`. // Useful on dual stacked instances where the default behavior is to // connect via whichever IP address is returned first from the OpenStack // API. SSHIPVersion string `mapstructure:"ssh_ip_version"` }
type StepConnect ¶
type StepConnect struct { // Config is the communicator config struct Config *Config // Host should return a host that can be connected to for communicator // connections. Host func(multistep.StateBag) (string, error) // The fields below are callbacks to assist with connecting to SSH. // // SSHConfig should return the default configuration for // connecting via SSH. SSHConfig func(multistep.StateBag) (*gossh.ClientConfig, error) SSHPort func(multistep.StateBag) (int, error) // The fields below are callbacks to assist with connecting to WinRM. // // WinRMConfig should return the default configuration for // connecting via WinRM. WinRMConfig func(multistep.StateBag) (*WinRMConfig, error) WinRMPort func(multistep.StateBag) (int, error) // CustomConnect can be set to have custom connectors for specific // types. These take highest precedence so you can also override // existing types. CustomConnect map[string]multistep.Step // contains filtered or unexported fields }
StepConnect is a multistep Step implementation that connects to the proper communicator and stores it in the "communicator" key in the state bag.
func (*StepConnect) Cleanup ¶
func (s *StepConnect) Cleanup(state multistep.StateBag)
func (*StepConnect) Run ¶
func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepConnectSSH ¶
type StepConnectSSH struct { // All the fields below are documented on StepConnect Config *Config Host func(multistep.StateBag) (string, error) SSHConfig func(multistep.StateBag) (*gossh.ClientConfig, error) SSHPort func(multistep.StateBag) (int, error) }
StepConnectSSH is a step that only connects to SSH.
In general, you should use StepConnect.
func (*StepConnectSSH) Cleanup ¶
func (s *StepConnectSSH) Cleanup(multistep.StateBag)
func (*StepConnectSSH) Run ¶
func (s *StepConnectSSH) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepConnectWinRM ¶
type StepConnectWinRM struct { // All the fields below are documented on StepConnect Config *Config Host func(multistep.StateBag) (string, error) WinRMConfig func(multistep.StateBag) (*WinRMConfig, error) WinRMPort func(multistep.StateBag) (int, error) }
StepConnectWinRM is a multistep Step implementation that waits for WinRM to become available. It gets the connection information from a single configuration when creating the step.
Uses:
ui packer.Ui
Produces:
communicator packer.Communicator
func (*StepConnectWinRM) Cleanup ¶
func (s *StepConnectWinRM) Cleanup(multistep.StateBag)
func (*StepConnectWinRM) Run ¶
func (s *StepConnectWinRM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type WinRM ¶ added in v1.4.4
type WinRM struct { // The username to use to connect to WinRM. WinRMUser string `mapstructure:"winrm_username"` // The password to use to connect to WinRM. WinRMPassword string `mapstructure:"winrm_password"` // The address for WinRM to connect to. // // NOTE: If using an Amazon EBS builder, you can specify the interface // WinRM connects to via // [`ssh_interface`](https://www.packer.io/docs/builders/amazon-ebs.html#ssh_interface) WinRMHost string `mapstructure:"winrm_host"` // The WinRM port to connect to. This defaults to `5985` for plain // unencrypted connection and `5986` for SSL when `winrm_use_ssl` is set to // true. WinRMPort int `mapstructure:"winrm_port"` // The amount of time to wait for WinRM to become available. This defaults // to `30m` since setting up a Windows machine generally takes a long time. WinRMTimeout time.Duration `mapstructure:"winrm_timeout"` // If `true`, use HTTPS for WinRM. WinRMUseSSL bool `mapstructure:"winrm_use_ssl"` // If `true`, do not check server certificate chain and host name. WinRMInsecure bool `mapstructure:"winrm_insecure"` // If `true`, NTLMv2 authentication (with session security) will be used // for WinRM, rather than default (basic authentication), removing the // requirement for basic authentication to be enabled within the target // guest. Further reading for remote connection authentication can be found // [here](https://msdn.microsoft.com/en-us/library/aa384295(v=vs.85).aspx). WinRMUseNTLM bool `mapstructure:"winrm_use_ntlm"` WinRMTransportDecorator func() winrm.Transporter }
func (*WinRM) ConfigSpec ¶ added in v1.5.0
func (c *WinRM) ConfigSpec() hcldec.ObjectSpec
func (*WinRM) FlatMapstructure ¶ added in v1.4.5
FlatMapstructure returns a new FlatWinRM. FlatWinRM is an auto-generated flat version of WinRM. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type WinRMConfig ¶
WinRMConfig is configuration that can be returned at runtime to dynamically configure WinRM.