Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Packer
Commits
20541a7e
Commit
20541a7e
authored
11 years ago
by
Mitchell Hashimoto
Browse files
Options
Download
Email Patches
Plain Diff
builder/vmware: ability to not request a PTY for SSH [GH-270]
parent
f626790e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
CHANGELOG.md
+2
-0
CHANGELOG.md
builder/vmware/builder.go
+2
-0
builder/vmware/builder.go
common/step_connect_ssh.go
+4
-0
common/step_connect_ssh.go
communicator/ssh/communicator.go
+13
-8
communicator/ssh/communicator.go
website/source/docs/builders/vmware.html.markdown
+4
-0
website/source/docs/builders/vmware.html.markdown
with
25 additions
and
8 deletions
+25
-8
CHANGELOG.md
+
2
-
0
View file @
20541a7e
...
...
@@ -14,6 +14,8 @@ IMPROVEMENTS:
*
core: Output message when Ctrl-C received that we're cleaning up. [GH-338]
*
builder/amazon: Tagging now works with all amazon builder types.
*
builder/vmware: Option
`ssh_skip_request_pty`
for not requesting a PTY
for the SSH connection. [GH-270]
*
command/build: Machine-readable output now contains build errors, if any.
*
command/build: An "end" sentinel is outputted in machine-readable output
for artifact listing so it is easier to know when it is over.
...
...
This diff is collapsed.
Click to expand it.
builder/vmware/builder.go
+
2
-
0
View file @
20541a7e
...
...
@@ -45,6 +45,7 @@ type config struct {
SSHUser
string
`mapstructure:"ssh_username"`
SSHPassword
string
`mapstructure:"ssh_password"`
SSHPort
uint
`mapstructure:"ssh_port"`
SSHSkipRequestPty
bool
`mapstructure:"ssh_skip_request_pty"`
ToolsUploadFlavor
string
`mapstructure:"tools_upload_flavor"`
ToolsUploadPath
string
`mapstructure:"tools_upload_path"`
VMXData
map
[
string
]
string
`mapstructure:"vmx_data"`
...
...
@@ -342,6 +343,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
SSHAddress
:
sshAddress
,
SSHConfig
:
sshConfig
,
SSHWaitTimeout
:
b
.
config
.
sshWaitTimeout
,
NoPty
:
b
.
config
.
SSHSkipRequestPty
,
},
&
stepUploadTools
{},
&
common
.
StepProvision
{},
...
...
This diff is collapsed.
Click to expand it.
common/step_connect_ssh.go
+
4
-
0
View file @
20541a7e
...
...
@@ -34,6 +34,9 @@ type StepConnectSSH struct {
// SSHWaitTimeout is the total timeout to wait for SSH to become available.
SSHWaitTimeout
time
.
Duration
// NoPty, if true, will not request a Pty from the remote end.
NoPty
bool
comm
packer
.
Communicator
}
...
...
@@ -128,6 +131,7 @@ func (s *StepConnectSSH) waitForSSH(state map[string]interface{}, cancel <-chan
config
:=
&
ssh
.
Config
{
Connection
:
connFunc
,
SSHConfig
:
sshConfig
,
NoPty
:
s
.
NoPty
,
}
log
.
Println
(
"Attempting SSH connection..."
)
...
...
This diff is collapsed.
Click to expand it.
communicator/ssh/communicator.go
+
13
-
8
View file @
20541a7e
...
...
@@ -29,6 +29,9 @@ type Config struct {
// in use will be closed as part of the Close method, or in the
// case an error occurs.
Connection
func
()
(
net
.
Conn
,
error
)
// NoPty, if true, will not request a pty from the remote end.
NoPty
bool
}
// Creates a new packer.Communicator implementation over SSH. This takes
...
...
@@ -58,15 +61,17 @@ func (c *comm) Start(cmd *packer.RemoteCmd) (err error) {
session
.
Stdout
=
cmd
.
Stdout
session
.
Stderr
=
cmd
.
Stderr
// Request a PTY
termModes
:=
ssh
.
TerminalModes
{
ssh
.
ECHO
:
0
,
// do not echo
ssh
.
TTY_OP_ISPEED
:
14400
,
// input speed = 14.4kbaud
ssh
.
TTY_OP_OSPEED
:
14400
,
// output speed = 14.4kbaud
}
if
!
c
.
config
.
NoPty
{
// Request a PTY
termModes
:=
ssh
.
TerminalModes
{
ssh
.
ECHO
:
0
,
// do not echo
ssh
.
TTY_OP_ISPEED
:
14400
,
// input speed = 14.4kbaud
ssh
.
TTY_OP_OSPEED
:
14400
,
// output speed = 14.4kbaud
}
if
err
=
session
.
RequestPty
(
"xterm"
,
80
,
40
,
termModes
);
err
!=
nil
{
return
if
err
=
session
.
RequestPty
(
"xterm"
,
80
,
40
,
termModes
);
err
!=
nil
{
return
}
}
log
.
Printf
(
"starting remote command: %s"
,
cmd
.
Command
)
...
...
This diff is collapsed.
Click to expand it.
website/source/docs/builders/vmware.html.markdown
+
4
-
0
View file @
20541a7e
...
...
@@ -154,6 +154,10 @@ Optional:
*
`ssh_port`
(int) - The port that SSH will listen on within the virtual
machine. By default this is 22.
*
`ssh_skip_request_pty`
(bool) - If true, a pty will not be requested as
part of the SSH connection. By default, this is "false", so a pty
_will_ be requested.
*
`ssh_wait_timeout`
(string) - The duration to wait for SSH to become
available. By default this is "20m", or 20 minutes. Note that this should
be quite long since the timer begins as soon as the virtual machine is booted.
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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