Documentation ¶
Overview ¶
Package communicator provides common steps for connecting to an instance using the Packer communicator. These steps can be implemented by builders. Normally, a builder will want to implement StepConnect, which is smart enough to then determine which kind of communicator, and therefore which kind of substep, it should implement.
Various helper functions are also supplied.
Index ¶
- Constants
- func CommHost(host string, statebagKey string) func(multistep.StateBag) (string, error)
- func ProxyTransportDecorator() winrmcmd.Transporter
- func ProxyTransportDecoratorWithNTLM() winrmcmd.Transporter
- func RefreshProxyFromEnvironment(req *http.Request) (*url.URL, 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 FlatSSHTemporaryKeyPair
- type FlatWinRM
- type SSH
- type SSHInterface
- type SSHTemporaryKeyPair
- type StepConnect
- type StepConnectSSH
- type StepConnectWinRM
- type StepDumpSSHKey
- type StepSSHKeyGen
- type WinRM
- type WinRMConfig
Constants ¶
const TestPEMContents = `` /* 1680-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func CommHost ¶
CommHost determines the IP address of the cloud instance that Packer should connect to. A custom CommHost function can be implemented in each builder if need be; this is a generic function that should work for most cloud builders.
func ProxyTransportDecorator ¶
func ProxyTransportDecorator() winrmcmd.Transporter
ProxyTransportDecorator is a custom Transporter that reloads HTTP Proxy settings at client runtime. The net/http ProxyFromEnvironment only loads the environment once, when the code is initialized rather than when it's executed. This means that if your wrapping code sets the NO_PROXY env var (as Packer does!), it will be ignored. Re-loading the environment vars is more expensive, but it is the easiest way to work around this limitation.
func ProxyTransportDecoratorWithNTLM ¶
func ProxyTransportDecoratorWithNTLM() winrmcmd.Transporter
ProxyTransportDecoratorWithNTLM is a custom Transporter that reloads HTTP Proxy settings at client runtime for NTLM. The net/http ProxyFromEnvironment only loads the environment once, when the code is initialized rather than when it's executed. This means that if your wrapping code sets the NO_PROXY env var (as Packer does!), it will be ignored. Re-loading the environment vars is more expensive, but it is the easiest way to work around this limitation.
func RefreshProxyFromEnvironment ¶
The net/http ProxyFromEnvironment only loads the environment once, when the code is initialized rather than when it's executed. This means that if your wrapping code sets the NO_PROXY env var (as Packer does!), it will be ignored. Re-loading the environment vars is more expensive, but it is the easiest way to work around this limitation.
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 if // you set `pause_before_connecting` to `10m` 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 a builder uses to define and configure a Packer communicator. Embed this struct in your builder config to implement communicator support.
func (*Config) FlatMapstructure ¶
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) Password ¶
Password returns the password that will be used for access based on config.
func (*Config) ReadSSHPrivateKeyFile ¶
ReadSSHPrivateKeyFile returns the SSH private key bytes.
func (*Config) SSHConfigFunc ¶
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 ¶
type FlatConfig struct { Type *string `mapstructure:"communicator" cty:"communicator" hcl:"communicator"` PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting" hcl:"pause_before_connecting"` SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host" hcl:"ssh_host"` SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port" hcl:"ssh_port"` SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username" hcl:"ssh_username"` SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password" hcl:"ssh_password"` SSHKeyPairName *string `mapstructure:"ssh_keypair_name" undocumented:"true" cty:"ssh_keypair_name" hcl:"ssh_keypair_name"` SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" undocumented:"true" cty:"temporary_key_pair_name" hcl:"temporary_key_pair_name"` SSHTemporaryKeyPairType *string `mapstructure:"temporary_key_pair_type" cty:"temporary_key_pair_type" hcl:"temporary_key_pair_type"` SSHTemporaryKeyPairBits *int `mapstructure:"temporary_key_pair_bits" cty:"temporary_key_pair_bits" hcl:"temporary_key_pair_bits"` SSHCiphers []string `mapstructure:"ssh_ciphers" cty:"ssh_ciphers" hcl:"ssh_ciphers"` SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys" hcl:"ssh_clear_authorized_keys"` SSHKEXAlgos []string `mapstructure:"ssh_key_exchange_algorithms" cty:"ssh_key_exchange_algorithms" hcl:"ssh_key_exchange_algorithms"` SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" undocumented:"true" cty:"ssh_private_key_file" hcl:"ssh_private_key_file"` SSHCertificateFile *string `mapstructure:"ssh_certificate_file" cty:"ssh_certificate_file" hcl:"ssh_certificate_file"` SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty" hcl:"ssh_pty"` SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout" hcl:"ssh_timeout"` SSHWaitTimeout *string `mapstructure:"ssh_wait_timeout" undocumented:"true" cty:"ssh_wait_timeout" hcl:"ssh_wait_timeout"` SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" undocumented:"true" cty:"ssh_agent_auth" hcl:"ssh_agent_auth"` SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding" hcl:"ssh_disable_agent_forwarding"` SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts" hcl:"ssh_handshake_attempts"` SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host" hcl:"ssh_bastion_host"` SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port" hcl:"ssh_bastion_port"` SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth" hcl:"ssh_bastion_agent_auth"` SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username" hcl:"ssh_bastion_username"` SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password" hcl:"ssh_bastion_password"` SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive" hcl:"ssh_bastion_interactive"` SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file" hcl:"ssh_bastion_private_key_file"` SSHBastionCertificateFile *string `mapstructure:"ssh_bastion_certificate_file" cty:"ssh_bastion_certificate_file" hcl:"ssh_bastion_certificate_file"` SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method" hcl:"ssh_file_transfer_method"` SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host" hcl:"ssh_proxy_host"` SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port" hcl:"ssh_proxy_port"` SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username" hcl:"ssh_proxy_username"` SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password" hcl:"ssh_proxy_password"` SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval" hcl:"ssh_keep_alive_interval"` SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout" hcl:"ssh_read_write_timeout"` SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels" hcl:"ssh_remote_tunnels"` SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels" hcl:"ssh_local_tunnels"` SSHPublicKey []byte `mapstructure:"ssh_public_key" undocumented:"true" cty:"ssh_public_key" hcl:"ssh_public_key"` SSHPrivateKey []byte `mapstructure:"ssh_private_key" undocumented:"true" cty:"ssh_private_key" hcl:"ssh_private_key"` WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username" hcl:"winrm_username"` WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password" hcl:"winrm_password"` WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host" hcl:"winrm_host"` WinRMNoProxy *bool `mapstructure:"winrm_no_proxy" cty:"winrm_no_proxy" hcl:"winrm_no_proxy"` WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port" hcl:"winrm_port"` WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout" hcl:"winrm_timeout"` WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl" hcl:"winrm_use_ssl"` WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure" hcl:"winrm_insecure"` WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm" hcl:"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 ¶
type FlatSSH struct { SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host" hcl:"ssh_host"` SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port" hcl:"ssh_port"` SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username" hcl:"ssh_username"` SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password" hcl:"ssh_password"` SSHKeyPairName *string `mapstructure:"ssh_keypair_name" undocumented:"true" cty:"ssh_keypair_name" hcl:"ssh_keypair_name"` SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" undocumented:"true" cty:"temporary_key_pair_name" hcl:"temporary_key_pair_name"` SSHTemporaryKeyPairType *string `mapstructure:"temporary_key_pair_type" cty:"temporary_key_pair_type" hcl:"temporary_key_pair_type"` SSHTemporaryKeyPairBits *int `mapstructure:"temporary_key_pair_bits" cty:"temporary_key_pair_bits" hcl:"temporary_key_pair_bits"` SSHCiphers []string `mapstructure:"ssh_ciphers" cty:"ssh_ciphers" hcl:"ssh_ciphers"` SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys" hcl:"ssh_clear_authorized_keys"` SSHKEXAlgos []string `mapstructure:"ssh_key_exchange_algorithms" cty:"ssh_key_exchange_algorithms" hcl:"ssh_key_exchange_algorithms"` SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" undocumented:"true" cty:"ssh_private_key_file" hcl:"ssh_private_key_file"` SSHCertificateFile *string `mapstructure:"ssh_certificate_file" cty:"ssh_certificate_file" hcl:"ssh_certificate_file"` SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty" hcl:"ssh_pty"` SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout" hcl:"ssh_timeout"` SSHWaitTimeout *string `mapstructure:"ssh_wait_timeout" undocumented:"true" cty:"ssh_wait_timeout" hcl:"ssh_wait_timeout"` SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" undocumented:"true" cty:"ssh_agent_auth" hcl:"ssh_agent_auth"` SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding" hcl:"ssh_disable_agent_forwarding"` SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts" hcl:"ssh_handshake_attempts"` SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host" hcl:"ssh_bastion_host"` SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port" hcl:"ssh_bastion_port"` SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth" hcl:"ssh_bastion_agent_auth"` SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username" hcl:"ssh_bastion_username"` SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password" hcl:"ssh_bastion_password"` SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive" hcl:"ssh_bastion_interactive"` SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file" hcl:"ssh_bastion_private_key_file"` SSHBastionCertificateFile *string `mapstructure:"ssh_bastion_certificate_file" cty:"ssh_bastion_certificate_file" hcl:"ssh_bastion_certificate_file"` SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method" hcl:"ssh_file_transfer_method"` SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host" hcl:"ssh_proxy_host"` SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port" hcl:"ssh_proxy_port"` SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username" hcl:"ssh_proxy_username"` SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password" hcl:"ssh_proxy_password"` SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval" hcl:"ssh_keep_alive_interval"` SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout" hcl:"ssh_read_write_timeout"` SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels" hcl:"ssh_remote_tunnels"` SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels" hcl:"ssh_local_tunnels"` SSHPublicKey []byte `mapstructure:"ssh_public_key" undocumented:"true" cty:"ssh_public_key" hcl:"ssh_public_key"` SSHPrivateKey []byte `mapstructure:"ssh_private_key" undocumented:"true" cty:"ssh_private_key" hcl:"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 FlatSSHTemporaryKeyPair ¶
type FlatSSHTemporaryKeyPair struct { SSHTemporaryKeyPairType *string `mapstructure:"temporary_key_pair_type" cty:"temporary_key_pair_type" hcl:"temporary_key_pair_type"` SSHTemporaryKeyPairBits *int `mapstructure:"temporary_key_pair_bits" cty:"temporary_key_pair_bits" hcl:"temporary_key_pair_bits"` }
FlatSSHTemporaryKeyPair is an auto-generated flat version of SSHTemporaryKeyPair. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatSSHTemporaryKeyPair) HCL2Spec ¶
func (*FlatSSHTemporaryKeyPair) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a SSHTemporaryKeyPair. This spec is used by HCL to read the fields of SSHTemporaryKeyPair. The decoded values from this spec will then be applied to a FlatSSHTemporaryKeyPair.
type FlatWinRM ¶
type FlatWinRM struct { WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username" hcl:"winrm_username"` WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password" hcl:"winrm_password"` WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host" hcl:"winrm_host"` WinRMNoProxy *bool `mapstructure:"winrm_no_proxy" cty:"winrm_no_proxy" hcl:"winrm_no_proxy"` WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port" hcl:"winrm_port"` WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout" hcl:"winrm_timeout"` WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl" hcl:"winrm_use_ssl"` WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure" hcl:"winrm_insecure"` WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm" hcl:"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 ¶
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 the remote. // By default, this is blank, and Packer will generate a temporary keypair // unless [`ssh_password`](#ssh_password) is used. // [`ssh_private_key_file`](#ssh_private_key_file) or // [`ssh_agent_auth`](#ssh_agent_auth) must be specified when // [`ssh_keypair_name`](#ssh_keypair_name) is utilized. SSHKeyPairName string `mapstructure:"ssh_keypair_name" undocumented:"true"` // 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" undocumented:"true"` SSHTemporaryKeyPair `mapstructure:",squash"` // This overrides the value of ciphers supported by default by golang. // The default value is [ // "aes128-gcm@openssh.com", // "chacha20-poly1305@openssh.com", // "aes128-ctr", "aes192-ctr", "aes256-ctr", // ] // // Valid options for ciphers include: // "aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", // "chacha20-poly1305@openssh.com", // "arcfour256", "arcfour128", "arcfour", "aes128-cbc", "3des-cbc", SSHCiphers []string `mapstructure:"ssh_ciphers"` // 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"` // If set, Packer will override the value of key exchange (kex) altorighms // supported by default by golang. Acceptable values include: // "curve25519-sha256@libssh.org", "ecdh-sha2-nistp256", // "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", // "diffie-hellman-group14-sha1", and "diffie-hellman-group1-sha1". SSHKEXAlgos []string `mapstructure:"ssh_key_exchange_algorithms"` // 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" undocumented:"true"` // Path to user certificate used to authenticate with SSH. // The `~` can be used in path and will be expanded to the // home directory of current user. SSHCertificateFile string `mapstructure:"ssh_certificate_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"` // Deprecated in favor of SSHTimeout SSHWaitTimeout time.Duration `mapstructure:"ssh_wait_timeout" undocumented:"true"` // 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`](#ssh_password) and // [`ssh_private_key_file`](#ssh_private_key_file) will be ignored. The // environment variable `SSH_AUTH_SOCK` must be set for this option to work // properly. SSHAgentAuth bool `mapstructure:"ssh_agent_auth" undocumented:"true"` // 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"` // If `true`, the keyboard-interactive used to authenticate with bastion host. SSHBastionInteractive bool `mapstructure:"ssh_bastion_interactive"` // 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"` // Path to user certificate used to authenticate with bastion host. // The `~` can be used in path and will be expanded to the //home directory of current user. SSHBastionCertificateFile string `mapstructure:"ssh_bastion_certificate_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" undocumented:"true"` SSHPrivateKey []byte `mapstructure:"ssh_private_key" undocumented:"true"` }
The SSH config defines configuration for the SSH communicator.
func (*SSH) ConfigSpec ¶
func (c *SSH) ConfigSpec() hcldec.ObjectSpec
The ConfigSpec funcs are used by the Packer core to parse HCL2 templates.
type SSHInterface ¶
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"` }
SSHInterface defines whether to use public or private, addresses, and whether to use IPv4 or IPv6.
type SSHTemporaryKeyPair ¶
type SSHTemporaryKeyPair struct { // `dsa` | `ecdsa` | `ed25519` | `rsa` ( the default ) // // Specifies the type of key to create. The possible values are 'dsa', // 'ecdsa', 'ed25519', or 'rsa'. SSHTemporaryKeyPairType string `mapstructure:"temporary_key_pair_type"` // Specifies the number of bits in the key to create. For RSA keys, the // minimum size is 1024 bits and the default is 4096 bits. Generally, 3072 // bits is considered sufficient. DSA keys must be exactly 1024 bits as // specified by FIPS 186-2. For ECDSA keys, bits determines the key length // by selecting from one of three elliptic curve sizes: 256, 384 or 521 // bits. Attempting to use bit lengths other than these three values for // ECDSA keys will fail. Ed25519 keys have a fixed length and bits will be // ignored. SSHTemporaryKeyPairBits int `mapstructure:"temporary_key_pair_bits"` }
When no ssh credentials are specified, Packer will generate a temporary SSH keypair for the instance. You can change the algorithm type and bits settings.
func (*SSHTemporaryKeyPair) FlatMapstructure ¶
func (*SSHTemporaryKeyPair) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatSSHTemporaryKeyPair. FlatSSHTemporaryKeyPair is an auto-generated flat version of SSHTemporaryKeyPair. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
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 packersdk.Ui
Produces:
communicator packersdk.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 StepDumpSSHKey ¶
StepDumpSSHKey is a multistep Step implementation that writes the ssh keypair somewhere.
func (*StepDumpSSHKey) Cleanup ¶
func (s *StepDumpSSHKey) Cleanup(state multistep.StateBag)
func (*StepDumpSSHKey) Run ¶
func (s *StepDumpSSHKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction
type StepSSHKeyGen ¶
type StepSSHKeyGen struct { CommConf *Config SSHTemporaryKeyPair }
StepSSHKeyGen is a Packer build step that generates SSH key pairs.
func (*StepSSHKeyGen) Cleanup ¶
func (s *StepSSHKeyGen) Cleanup(state multistep.StateBag)
Nothing to clean up. SSH keys are associated with a single GCE instance.
func (*StepSSHKeyGen) Run ¶
func (s *StepSSHKeyGen) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that generates SSH key pairs. The key pairs are added to the ssh config
type WinRM ¶
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`](/docs/builders/amazon-ebs#ssh_interface) WinRMHost string `mapstructure:"winrm_host"` // Setting this to `true` adds the remote // `host:port` to the `NO_PROXY` environment variable. This has the effect of // bypassing any configured proxies when connecting to the remote host. // Default to `false`. WinRMNoProxy bool `mapstructure:"winrm_no_proxy"` // 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 }
The WinRM config defines configuration for the WinRM communicator.
func (*WinRM) ConfigSpec ¶
func (c *WinRM) ConfigSpec() hcldec.ObjectSpec
The ConfigSpec funcs are used by the Packer core to parse HCL2 templates.
type WinRMConfig ¶
WinRMConfig is configuration that can be returned at runtime to dynamically configure WinRM.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package SSH provides tooling for generating a temporary SSH keypair, and provides tooling for connecting to an instance via a tunnel.
|
Package SSH provides tooling for generating a temporary SSH keypair, and provides tooling for connecting to an instance via a tunnel. |