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
a93a1797
Commit
a93a1797
authored
Sep 05, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #389 from whostolebenfrog/master
builder/amazon/ebs: Allow customization of temporary ssh key name
parents
e732d861
f9538744
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
5 deletions
+33
-5
builder/amazon/common/run_config.go
builder/amazon/common/run_config.go
+5
-0
builder/amazon/common/run_config_test.go
builder/amazon/common/run_config_test.go
+21
-0
builder/amazon/common/step_key_pair.go
builder/amazon/common/step_key_pair.go
+4
-3
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+3
-2
No files found.
builder/amazon/common/run_config.go
View file @
a93a1797
...
@@ -22,6 +22,7 @@ type RunConfig struct {
...
@@ -22,6 +22,7 @@ type RunConfig struct {
SecurityGroupId
string
`mapstructure:"security_group_id"`
SecurityGroupId
string
`mapstructure:"security_group_id"`
SubnetId
string
`mapstructure:"subnet_id"`
SubnetId
string
`mapstructure:"subnet_id"`
VpcId
string
`mapstructure:"vpc_id"`
VpcId
string
`mapstructure:"vpc_id"`
SSHKeyPairPattern
string
`mapstructure:"ssh_keypair_pattern"`
// Unexported fields that are calculated from others
// Unexported fields that are calculated from others
sshTimeout
time
.
Duration
sshTimeout
time
.
Duration
...
@@ -45,6 +46,10 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
...
@@ -45,6 +46,10 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
c
.
RawSSHTimeout
=
"1m"
c
.
RawSSHTimeout
=
"1m"
}
}
if
c
.
SSHKeyPairPattern
==
""
{
c
.
SSHKeyPairPattern
=
"packer %s"
}
// Validation
// Validation
var
err
error
var
err
error
errs
:=
make
([]
error
,
0
)
errs
:=
make
([]
error
,
0
)
...
...
builder/amazon/common/run_config_test.go
View file @
a93a1797
...
@@ -126,3 +126,24 @@ func TestRunConfigPrepare_UserDataFile(t *testing.T) {
...
@@ -126,3 +126,24 @@ func TestRunConfigPrepare_UserDataFile(t *testing.T) {
t
.
Fatalf
(
"err: %s"
,
err
)
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
}
}
func
TestRunConfigPrepare_SSHKeyPairPattern
(
t
*
testing
.
T
)
{
c
:=
testConfig
()
c
.
SSHKeyPairPattern
=
""
if
err
:=
c
.
Prepare
(
nil
);
len
(
err
)
!=
0
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
c
.
SSHKeyPairPattern
!=
"packer %s"
{
t
.
Fatalf
(
"invalid value: %s"
,
c
.
SSHKeyPairPattern
)
}
c
.
SSHKeyPairPattern
=
"valid-%s"
if
err
:=
c
.
Prepare
(
nil
);
len
(
err
)
!=
0
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
c
.
SSHKeyPairPattern
!=
"valid-%s"
{
t
.
Fatalf
(
"invalid value: %s"
,
c
.
SSHKeyPairPattern
)
}
}
builder/amazon/common/step_key_pair.go
View file @
a93a1797
...
@@ -13,8 +13,9 @@ import (
...
@@ -13,8 +13,9 @@ import (
)
)
type
StepKeyPair
struct
{
type
StepKeyPair
struct
{
Debug
bool
Debug
bool
DebugKeyPath
string
DebugKeyPath
string
KeyPairPattern
string
keyName
string
keyName
string
}
}
...
@@ -24,7 +25,7 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -24,7 +25,7 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Say
(
"Creating temporary keypair for this instance..."
)
ui
.
Say
(
"Creating temporary keypair for this instance..."
)
keyName
:=
fmt
.
Sprintf
(
"packer %s"
,
hex
.
EncodeToString
(
identifier
.
NewUUID
()
.
Raw
()))
keyName
:=
fmt
.
Sprintf
(
s
.
KeyPairPattern
,
hex
.
EncodeToString
(
identifier
.
NewUUID
()
.
Raw
()))
log
.
Printf
(
"temporary keypair name: %s"
,
keyName
)
log
.
Printf
(
"temporary keypair name: %s"
,
keyName
)
keyResp
,
err
:=
ec2conn
.
CreateKeyPair
(
keyName
)
keyResp
,
err
:=
ec2conn
.
CreateKeyPair
(
keyName
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
builder/amazon/ebs/builder.go
View file @
a93a1797
...
@@ -82,8 +82,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -82,8 +82,9 @@ 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
),
KeyPairPattern
:
b
.
config
.
SSHKeyPairPattern
,
},
},
&
awscommon
.
StepSecurityGroup
{
&
awscommon
.
StepSecurityGroup
{
SecurityGroupId
:
b
.
config
.
SecurityGroupId
,
SecurityGroupId
:
b
.
config
.
SecurityGroupId
,
...
...
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