force tty allocation for ssh with multiple '-tt'.

fix #2037:
when provision on CentOS 7.0, it needs to force tty allocation with multiple '-t' option.
Otherwise, the ssh command will failed with "sudo: sorry, you must have a tty to run sudo"
in SetHostname.

Signed-off-by: Xiaohui Liu <xiaohui.liu@ucloud.cn>
This commit is contained in:
Xiaohui Liu 2015-10-22 16:14:47 +08:00
parent a1e610bdd3
commit 27cdffe042
1 changed files with 4 additions and 2 deletions

View File

@ -73,10 +73,12 @@ func (provisioner *RedHatProvisioner) SSHCommand(args string) (string, error) {
}
// redhat needs "-t" for tty allocation on ssh therefore we check for the
// external client and add as needed
// external client and add as needed.
// Note: CentOS 7.0 needs multiple "-tt" to force tty allocation when ssh has
// no local tty.
switch c := client.(type) {
case ssh.ExternalClient:
c.BaseArgs = append(c.BaseArgs, "-t")
c.BaseArgs = append(c.BaseArgs, "-tt")
client = c
case ssh.NativeClient:
return c.OutputWithPty(args)