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
c908fdbb
Commit
c908fdbb
authored
Jun 15, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'nyetsche-master'
parents
b15a7766
de2004c1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
20 deletions
+29
-20
builder/amazon/common/run_config.go
builder/amazon/common/run_config.go
+5
-3
builder/amazon/common/step_key_pair.go
builder/amazon/common/step_key_pair.go
+14
-9
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+5
-4
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+5
-4
No files found.
builder/amazon/common/run_config.go
View file @
c908fdbb
...
@@ -33,11 +33,13 @@ type RunConfig struct {
...
@@ -33,11 +33,13 @@ type RunConfig struct {
// Communicator settings
// Communicator settings
Comm
communicator
.
Config
`mapstructure:",squash"`
Comm
communicator
.
Config
`mapstructure:",squash"`
SSHKeyPairName
string
`mapstructure:"ssh_keypair_name"`
SSHPrivateIp
bool
`mapstructure:"ssh_private_ip"`
SSHPrivateIp
bool
`mapstructure:"ssh_private_ip"`
}
}
func
(
c
*
RunConfig
)
Prepare
(
ctx
*
interpolate
.
Context
)
[]
error
{
func
(
c
*
RunConfig
)
Prepare
(
ctx
*
interpolate
.
Context
)
[]
error
{
if
c
.
TemporaryKeyPairName
==
""
{
// if we are not given an explicit keypairname, create a temporary one
if
c
.
SSHKeyPairName
==
""
{
c
.
TemporaryKeyPairName
=
fmt
.
Sprintf
(
c
.
TemporaryKeyPairName
=
fmt
.
Sprintf
(
"packer %s"
,
uuid
.
TimeOrderedUUID
())
"packer %s"
,
uuid
.
TimeOrderedUUID
())
}
}
...
...
builder/amazon/common/step_key_pair.go
View file @
c908fdbb
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
type
StepKeyPair
struct
{
type
StepKeyPair
struct
{
Debug
bool
Debug
bool
DebugKeyPath
string
DebugKeyPath
string
TemporaryKeyPairName
string
KeyPairName
string
KeyPairName
string
PrivateKeyFile
string
PrivateKeyFile
string
...
@@ -22,7 +23,9 @@ type StepKeyPair struct {
...
@@ -22,7 +23,9 @@ type StepKeyPair struct {
func
(
s
*
StepKeyPair
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
s
*
StepKeyPair
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
if
s
.
PrivateKeyFile
!=
""
{
if
s
.
PrivateKeyFile
!=
""
{
s
.
keyName
=
""
if
s
.
KeyPairName
!=
""
{
s
.
keyName
=
s
.
KeyPairName
// need to get from config
}
privateKeyBytes
,
err
:=
ioutil
.
ReadFile
(
s
.
PrivateKeyFile
)
privateKeyBytes
,
err
:=
ioutil
.
ReadFile
(
s
.
PrivateKeyFile
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -30,7 +33,7 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -30,7 +33,7 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
state
.
Put
(
"keyPair"
,
""
)
state
.
Put
(
"keyPair"
,
s
.
keyName
)
state
.
Put
(
"privateKey"
,
string
(
privateKeyBytes
))
state
.
Put
(
"privateKey"
,
string
(
privateKeyBytes
))
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
...
@@ -39,7 +42,7 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -39,7 +42,7 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
ec2conn
:=
state
.
Get
(
"ec2"
)
.
(
*
ec2
.
EC2
)
ec2conn
:=
state
.
Get
(
"ec2"
)
.
(
*
ec2
.
EC2
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Say
(
fmt
.
Sprintf
(
"Creating temporary keypair: %s"
,
s
.
KeyPairName
))
ui
.
Say
(
fmt
.
Sprintf
(
"Creating temporary keypair: %s"
,
s
.
Temporary
KeyPairName
))
keyResp
,
err
:=
ec2conn
.
CreateKeyPair
(
&
ec2
.
CreateKeyPairInput
{
KeyName
:
&
s
.
KeyPairName
})
keyResp
,
err
:=
ec2conn
.
CreateKeyPair
(
&
ec2
.
CreateKeyPairInput
{
KeyName
:
&
s
.
KeyPairName
})
if
err
!=
nil
{
if
err
!=
nil
{
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error creating temporary keypair: %s"
,
err
))
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error creating temporary keypair: %s"
,
err
))
...
@@ -47,7 +50,7 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -47,7 +50,7 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
}
}
// Set the keyname so we know to delete it later
// Set the keyname so we know to delete it later
s
.
keyName
=
s
.
KeyPairName
s
.
keyName
=
s
.
Temporary
KeyPairName
// Set some state data for use in future steps
// Set some state data for use in future steps
state
.
Put
(
"keyPair"
,
s
.
keyName
)
state
.
Put
(
"keyPair"
,
s
.
keyName
)
...
@@ -84,7 +87,9 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -84,7 +87,9 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
func
(
s
*
StepKeyPair
)
Cleanup
(
state
multistep
.
StateBag
)
{
func
(
s
*
StepKeyPair
)
Cleanup
(
state
multistep
.
StateBag
)
{
// If no key name is set, then we never created it, so just return
// If no key name is set, then we never created it, so just return
if
s
.
keyName
==
""
{
// If we used an SSH private key file, do not go about deleting
// keypairs
if
s
.
PrivateKeyFile
!=
""
{
return
return
}
}
...
...
builder/amazon/ebs/builder.go
View file @
c908fdbb
...
@@ -91,6 +91,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -91,6 +91,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
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
,
TemporaryKeyPairName
:
b
.
config
.
TemporaryKeyPairName
,
PrivateKeyFile
:
b
.
config
.
RunConfig
.
Comm
.
SSHPrivateKey
,
PrivateKeyFile
:
b
.
config
.
RunConfig
.
Comm
.
SSHPrivateKey
,
},
},
&
awscommon
.
StepSecurityGroup
{
&
awscommon
.
StepSecurityGroup
{
...
...
builder/amazon/instance/builder.go
View file @
c908fdbb
...
@@ -181,6 +181,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -181,6 +181,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
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
.
RunConfig
.
Comm
.
SSHPrivateKey
,
PrivateKeyFile
:
b
.
config
.
RunConfig
.
Comm
.
SSHPrivateKey
,
TemporaryKeyPairName
:
b
.
config
.
TemporaryKeyPairName
,
},
},
&
awscommon
.
StepSecurityGroup
{
&
awscommon
.
StepSecurityGroup
{
CommConfig
:
&
b
.
config
.
RunConfig
.
Comm
,
CommConfig
:
&
b
.
config
.
RunConfig
.
Comm
,
...
...
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