Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
ef189808
Commit
ef189808
authored
Apr 21, 2014
by
Ross Smith II
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #971 from fnoeding/amazon-sshkey
optionally use existing ssh key for amazon builders
parents
e94a7e7f
6371b706
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
9 deletions
+36
-9
builder/amazon/common/run_config.go
builder/amazon/common/run_config.go
+2
-0
builder/amazon/common/step_key_pair.go
builder/amazon/common/step_key_pair.go
+20
-3
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+4
-3
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+4
-3
website/source/docs/builders/amazon-ebs.html.markdown
website/source/docs/builders/amazon-ebs.html.markdown
+3
-0
website/source/docs/builders/amazon-instance.html.markdown
website/source/docs/builders/amazon-instance.html.markdown
+3
-0
No files found.
builder/amazon/common/run_config.go
View file @
ef189808
...
@@ -19,6 +19,7 @@ type RunConfig struct {
...
@@ -19,6 +19,7 @@ type RunConfig struct {
SourceAmi
string
`mapstructure:"source_ami"`
SourceAmi
string
`mapstructure:"source_ami"`
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHPrivateKeyFile
string
`mapstructure:"ssh_private_key_file"`
SSHPort
int
`mapstructure:"ssh_port"`
SSHPort
int
`mapstructure:"ssh_port"`
SecurityGroupId
string
`mapstructure:"security_group_id"`
SecurityGroupId
string
`mapstructure:"security_group_id"`
SecurityGroupIds
[]
string
`mapstructure:"security_group_ids"`
SecurityGroupIds
[]
string
`mapstructure:"security_group_ids"`
...
@@ -91,6 +92,7 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
...
@@ -91,6 +92,7 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
"instance_type"
:
&
c
.
InstanceType
,
"instance_type"
:
&
c
.
InstanceType
,
"ssh_timeout"
:
&
c
.
RawSSHTimeout
,
"ssh_timeout"
:
&
c
.
RawSSHTimeout
,
"ssh_username"
:
&
c
.
SSHUsername
,
"ssh_username"
:
&
c
.
SSHUsername
,
"ssh_private_key_file"
:
&
c
.
SSHPrivateKeyFile
,
"source_ami"
:
&
c
.
SourceAmi
,
"source_ami"
:
&
c
.
SourceAmi
,
"subnet_id"
:
&
c
.
SubnetId
,
"subnet_id"
:
&
c
.
SubnetId
,
"temporary_key_pair_name"
:
&
c
.
TemporaryKeyPairName
,
"temporary_key_pair_name"
:
&
c
.
TemporaryKeyPairName
,
...
...
builder/amazon/common/step_key_pair.go
View file @
ef189808
...
@@ -5,19 +5,36 @@ import (
...
@@ -5,19 +5,36 @@ import (
"github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"io/ioutil"
"os"
"os"
"runtime"
"runtime"
)
)
type
StepKeyPair
struct
{
type
StepKeyPair
struct
{
Debug
bool
Debug
bool
DebugKeyPath
string
DebugKeyPath
string
KeyPairName
string
KeyPairName
string
PrivateKeyFile
string
keyName
string
keyName
string
}
}
func
(
s
*
StepKeyPair
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
s
*
StepKeyPair
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
if
s
.
PrivateKeyFile
!=
""
{
s
.
keyName
=
""
privateKeyBytes
,
err
:=
ioutil
.
ReadFile
(
s
.
PrivateKeyFile
)
if
err
!=
nil
{
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error loading configured private key file: %s"
,
err
))
return
multistep
.
ActionHalt
}
state
.
Put
(
"keyPair"
,
""
)
state
.
Put
(
"privateKey"
,
string
(
privateKeyBytes
))
return
multistep
.
ActionContinue
}
ec2conn
:=
state
.
Get
(
"ec2"
)
.
(
*
ec2
.
EC2
)
ec2conn
:=
state
.
Get
(
"ec2"
)
.
(
*
ec2
.
EC2
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
...
...
builder/amazon/ebs/builder.go
View file @
ef189808
...
@@ -83,9 +83,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -83,9 +83,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
// Build the steps
// Build the steps
steps
:=
[]
multistep
.
Step
{
steps
:=
[]
multistep
.
Step
{
&
awscommon
.
StepKeyPair
{
&
awscommon
.
StepKeyPair
{
Debug
:
b
.
config
.
PackerDebug
,
Debug
:
b
.
config
.
PackerDebug
,
DebugKeyPath
:
fmt
.
Sprintf
(
"ec2_%s.pem"
,
b
.
config
.
PackerBuildName
),
DebugKeyPath
:
fmt
.
Sprintf
(
"ec2_%s.pem"
,
b
.
config
.
PackerBuildName
),
KeyPairName
:
b
.
config
.
TemporaryKeyPairName
,
KeyPairName
:
b
.
config
.
TemporaryKeyPairName
,
PrivateKeyFile
:
b
.
config
.
SSHPrivateKeyFile
,
},
},
&
awscommon
.
StepSecurityGroup
{
&
awscommon
.
StepSecurityGroup
{
SecurityGroupIds
:
b
.
config
.
SecurityGroupIds
,
SecurityGroupIds
:
b
.
config
.
SecurityGroupIds
,
...
...
builder/amazon/instance/builder.go
View file @
ef189808
...
@@ -187,9 +187,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -187,9 +187,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
// Build the steps
// Build the steps
steps
:=
[]
multistep
.
Step
{
steps
:=
[]
multistep
.
Step
{
&
awscommon
.
StepKeyPair
{
&
awscommon
.
StepKeyPair
{
Debug
:
b
.
config
.
PackerDebug
,
Debug
:
b
.
config
.
PackerDebug
,
DebugKeyPath
:
fmt
.
Sprintf
(
"ec2_%s.pem"
,
b
.
config
.
PackerBuildName
),
DebugKeyPath
:
fmt
.
Sprintf
(
"ec2_%s.pem"
,
b
.
config
.
PackerBuildName
),
KeyPairName
:
b
.
config
.
TemporaryKeyPairName
,
KeyPairName
:
b
.
config
.
TemporaryKeyPairName
,
PrivateKeyFile
:
b
.
config
.
SSHPrivateKeyFile
,
},
},
&
awscommon
.
StepSecurityGroup
{
&
awscommon
.
StepSecurityGroup
{
SecurityGroupIds
:
b
.
config
.
SecurityGroupIds
,
SecurityGroupIds
:
b
.
config
.
SecurityGroupIds
,
...
...
website/source/docs/builders/amazon-ebs.html.markdown
View file @
ef189808
...
@@ -108,6 +108,9 @@ Optional:
...
@@ -108,6 +108,9 @@ Optional:
*
`ssh_port`
(int) - The port that SSH will be available on. This defaults
*
`ssh_port`
(int) - The port that SSH will be available on. This defaults
to port 22.
to port 22.
*
`ssh_private_key_file`
- Use this ssh private key file instead of a generated
ssh key pair for connecting to the instance.
*
`ssh_timeout`
(string) - The time to wait for SSH to become available
*
`ssh_timeout`
(string) - The time to wait for SSH to become available
before timing out. The format of this value is a duration such as "5s"
before timing out. The format of this value is a duration such as "5s"
or "5m". The default SSH timeout is "5m", or five minutes.
or "5m". The default SSH timeout is "5m", or five minutes.
...
...
website/source/docs/builders/amazon-instance.html.markdown
View file @
ef189808
...
@@ -147,6 +147,9 @@ Optional:
...
@@ -147,6 +147,9 @@ Optional:
*
`ssh_port`
(int) - The port that SSH will be available on. This defaults
*
`ssh_port`
(int) - The port that SSH will be available on. This defaults
to port 22.
to port 22.
*
`ssh_private_key_file`
- Use this ssh private key file instead of a generated
ssh key pair for connecting to the instance.
*
`ssh_timeout`
(string) - The time to wait for SSH to become available
*
`ssh_timeout`
(string) - The time to wait for SSH to become available
before timing out. The format of this value is a duration such as "5s"
before timing out. The format of this value is a duration such as "5s"
or "5m". The default SSH timeout is "5m", or five minutes.
or "5m". The default SSH timeout is "5m", or five minutes.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment