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
8f6ecfd9
Commit
8f6ecfd9
authored
Jun 13, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon: various fixes (minor) to get things going
parent
dc8c9489
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
10 deletions
+38
-10
builder/amazon/common/step_get_password.go
builder/amazon/common/step_get_password.go
+6
-2
builder/amazon/common/step_run_source_instance.go
builder/amazon/common/step_run_source_instance.go
+8
-0
builder/amazon/common/step_security_group.go
builder/amazon/common/step_security_group.go
+10
-6
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+1
-1
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+1
-1
helper/communicator/config.go
helper/communicator/config.go
+12
-0
No files found.
builder/amazon/common/step_get_password.go
View file @
8f6ecfd9
...
...
@@ -48,7 +48,9 @@ func (s *StepGetPassword) Run(state multistep.StateBag) multistep.StepAction {
ui
.
Say
(
"Waiting for auto-generated password for instance..."
)
ui
.
Message
(
"It is normal for this process to take up to 15 minutes,
\n
"
+
"but it usually takes around 5. Please wait."
)
"but it usually takes around 5. Please wait. After the
\n
"
+
"password is read, it will printed out below. Since it should
\n
"
+
"be a temporary password, this should be a minimal security risk."
)
password
,
err
=
s
.
waitForPassword
(
state
,
cancel
)
waitDone
<-
true
}()
...
...
@@ -66,7 +68,7 @@ WaitLoop:
return
multistep
.
ActionHalt
}
ui
.
Message
(
"Password retrieved!"
)
ui
.
Message
(
fmt
.
Sprintf
(
"
\n
Password retrieved: %s"
,
password
)
)
s
.
Comm
.
WinRMPassword
=
password
break
WaitLoop
case
<-
timeout
:
...
...
@@ -121,6 +123,8 @@ func (s *StepGetPassword) waitForPassword(state multistep.StateBag, cancel <-cha
return
decryptedPassword
,
nil
}
log
.
Printf
(
"[DEBUG] Password is blank, will retry..."
)
}
}
...
...
builder/amazon/common/step_run_source_instance.go
View file @
8f6ecfd9
package
common
import
(
"encoding/base64"
"fmt"
"io/ioutil"
"log"
...
...
@@ -53,7 +54,14 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
return
multistep
.
ActionHalt
}
// Test if it is encoded already, and if not, encode it
if
_
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
string
(
contents
));
err
!=
nil
{
log
.
Printf
(
"[DEBUG] base64 encoding user data..."
)
contents
=
[]
byte
(
base64
.
StdEncoding
.
EncodeToString
(
contents
))
}
userData
=
string
(
contents
)
}
ui
.
Say
(
"Launching a source AWS instance..."
)
...
...
builder/amazon/common/step_security_group.go
View file @
8f6ecfd9
...
...
@@ -9,12 +9,13 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/packer"
)
type
StepSecurityGroup
struct
{
CommConfig
*
communicator
.
Config
SecurityGroupIds
[]
string
SSHPort
int
VpcId
string
createdGroupId
string
...
...
@@ -30,8 +31,9 @@ func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionContinue
}
if
s
.
SSHPort
==
0
{
panic
(
"SSHPort must be set to a non-zero value."
)
port
:=
s
.
CommConfig
.
Port
()
if
port
==
0
{
panic
(
"port must be set to a non-zero value."
)
}
// Create the group
...
...
@@ -57,15 +59,17 @@ func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction {
req
:=
&
ec2
.
AuthorizeSecurityGroupIngressInput
{
GroupID
:
groupResp
.
GroupID
,
IPProtocol
:
aws
.
String
(
"tcp"
),
FromPort
:
aws
.
Long
(
int64
(
s
.
SSHP
ort
)),
ToPort
:
aws
.
Long
(
int64
(
s
.
SSHP
ort
)),
FromPort
:
aws
.
Long
(
int64
(
p
ort
)),
ToPort
:
aws
.
Long
(
int64
(
p
ort
)),
CIDRIP
:
aws
.
String
(
"0.0.0.0/0"
),
}
// We loop and retry this a few times because sometimes the security
// group isn't available immediately because AWS resources are eventaully
// consistent.
ui
.
Say
(
"Authorizing SSH access on the temporary security group..."
)
ui
.
Say
(
fmt
.
Sprintf
(
"Authorizing access to port %d the temporary security group..."
,
port
))
for
i
:=
0
;
i
<
5
;
i
++
{
_
,
err
=
ec2conn
.
AuthorizeSecurityGroupIngress
(
req
)
if
err
==
nil
{
...
...
builder/amazon/ebs/builder.go
View file @
8f6ecfd9
...
...
@@ -94,7 +94,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
&
awscommon
.
StepSecurityGroup
{
SecurityGroupIds
:
b
.
config
.
SecurityGroupIds
,
SSHPort
:
b
.
config
.
RunConfig
.
Comm
.
SSHPort
,
CommConfig
:
&
b
.
config
.
RunConfig
.
Comm
,
VpcId
:
b
.
config
.
VpcId
,
},
&
awscommon
.
StepRunSourceInstance
{
...
...
builder/amazon/instance/builder.go
View file @
8f6ecfd9
...
...
@@ -179,8 +179,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
PrivateKeyFile
:
b
.
config
.
RunConfig
.
Comm
.
SSHPrivateKey
,
},
&
awscommon
.
StepSecurityGroup
{
CommConfig
:
&
b
.
config
.
RunConfig
.
Comm
,
SecurityGroupIds
:
b
.
config
.
SecurityGroupIds
,
SSHPort
:
b
.
config
.
RunConfig
.
Comm
.
SSHPort
,
VpcId
:
b
.
config
.
VpcId
,
},
&
awscommon
.
StepRunSourceInstance
{
...
...
helper/communicator/config.go
View file @
8f6ecfd9
...
...
@@ -31,6 +31,18 @@ type Config struct {
WinRMTimeout
time
.
Duration
`mapstructure:"winrm_timeout"`
}
// Port returns the port that will be used for access based on config.
func
(
c
*
Config
)
Port
()
int
{
switch
c
.
Type
{
case
"ssh"
:
return
c
.
SSHPort
case
"winrm"
:
return
c
.
WinRMPort
default
:
return
0
}
}
func
(
c
*
Config
)
Prepare
(
ctx
*
interpolate
.
Context
)
[]
error
{
if
c
.
Type
==
""
{
c
.
Type
=
"ssh"
...
...
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