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
ff6a0915
Commit
ff6a0915
authored
Jul 27, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2512 from hazelesque/openstack-support-using-existing-keypair
openstack builder: support using existing keypair
parents
bd0ee8d3
b47eb4ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
0 deletions
+26
-0
builder/openstack/builder.go
builder/openstack/builder.go
+2
-0
builder/openstack/run_config.go
builder/openstack/run_config.go
+1
-0
builder/openstack/step_key_pair.go
builder/openstack/step_key_pair.go
+23
-0
No files found.
builder/openstack/builder.go
View file @
ff6a0915
...
...
@@ -77,6 +77,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
StepKeyPair
{
Debug
:
b
.
config
.
PackerDebug
,
DebugKeyPath
:
fmt
.
Sprintf
(
"os_%s.pem"
,
b
.
config
.
PackerBuildName
),
KeyPairName
:
b
.
config
.
SSHKeyPairName
,
PrivateKeyFile
:
b
.
config
.
RunConfig
.
Comm
.
SSHPrivateKey
,
},
&
StepRunSourceServer
{
Name
:
b
.
config
.
ImageName
,
...
...
builder/openstack/run_config.go
View file @
ff6a0915
...
...
@@ -11,6 +11,7 @@ import (
// image and details on how to access that launched image.
type
RunConfig
struct
{
Comm
communicator
.
Config
`mapstructure:",squash"`
SSHKeyPairName
string
`mapstructure:"ssh_keypair_name"`
SSHInterface
string
`mapstructure:"ssh_interface"`
SourceImage
string
`mapstructure:"source_image"`
...
...
builder/openstack/step_key_pair.go
View file @
ff6a0915
...
...
@@ -2,6 +2,7 @@ package openstack
import
(
"fmt"
"io/ioutil"
"os"
"runtime"
...
...
@@ -14,10 +15,27 @@ import (
type
StepKeyPair
struct
{
Debug
bool
DebugKeyPath
string
KeyPairName
string
PrivateKeyFile
string
keyName
string
}
func
(
s
*
StepKeyPair
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
if
s
.
PrivateKeyFile
!=
""
{
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"
,
s
.
KeyPairName
)
state
.
Put
(
"privateKey"
,
string
(
privateKeyBytes
))
return
multistep
.
ActionContinue
}
config
:=
state
.
Get
(
"config"
)
.
(
Config
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
...
...
@@ -81,6 +99,11 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
}
func
(
s
*
StepKeyPair
)
Cleanup
(
state
multistep
.
StateBag
)
{
// If we used an SSH private key file, do not go about deleting
// keypairs
if
s
.
PrivateKeyFile
!=
""
{
return
}
// If no key name is set, then we never created it, so just return
if
s
.
keyName
==
""
{
return
...
...
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