adding public_ssh_port flag to use a fixed port in the forwarding rules
This commit is contained in:
parent
d1cc5451e9
commit
d90dfc096a
|
@ -38,6 +38,7 @@ type Config struct {
|
||||||
Network string `mapstructure:"network"`
|
Network string `mapstructure:"network"`
|
||||||
Project string `mapstructure:"project"`
|
Project string `mapstructure:"project"`
|
||||||
PublicIPAddress string `mapstructure:"public_ip_address"`
|
PublicIPAddress string `mapstructure:"public_ip_address"`
|
||||||
|
PublicSSHPort int `mapstructure:"public_ssh_port"`
|
||||||
SecurityGroups []string `mapstructure:"security_groups"`
|
SecurityGroups []string `mapstructure:"security_groups"`
|
||||||
ServiceOffering string `mapstructure:"service_offering"`
|
ServiceOffering string `mapstructure:"service_offering"`
|
||||||
PreventFirewallChanges bool `mapstructure:"prevent_firewall_changes"`
|
PreventFirewallChanges bool `mapstructure:"prevent_firewall_changes"`
|
||||||
|
|
|
@ -31,9 +31,13 @@ func (s *stepSetupNetworking) Run(_ context.Context, state multistep.StateBag) m
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a random public port used to configure our port forward.
|
if config.PublicSSHPort != 0 {
|
||||||
rand.Seed(time.Now().UnixNano())
|
s.publicPort = config.PublicSSHPort
|
||||||
s.publicPort = 50000 + rand.Intn(10000)
|
} else {
|
||||||
|
// Generate a random public port used to configure our port forward.
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
s.publicPort = 50000 + rand.Intn(10000)
|
||||||
|
}
|
||||||
state.Put("commPort", s.publicPort)
|
state.Put("commPort", s.publicPort)
|
||||||
|
|
||||||
// Set the currently configured port to be the private port.
|
// Set the currently configured port to be the private port.
|
||||||
|
|
|
@ -126,6 +126,10 @@ builder.
|
||||||
connecting any provisioners to. If not provided, a temporary public IP
|
connecting any provisioners to. If not provided, a temporary public IP
|
||||||
address will be associated and released during the Packer run.
|
address will be associated and released during the Packer run.
|
||||||
|
|
||||||
|
- `public_ssh_port` (number) - The fixed port you want to configure in the port
|
||||||
|
forwarding rule. Set this attribute if you do not want to use the a random
|
||||||
|
public port.
|
||||||
|
|
||||||
- `security_groups` (array of strings) - A list of security group IDs or names
|
- `security_groups` (array of strings) - A list of security group IDs or names
|
||||||
to associate the instance with.
|
to associate the instance with.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue