Merge pull request #3392 from msteinhoff/fix-ansible-provisioner-long-lines

Fix Scanner buffer too long error in ansible-remote provisioner
This commit is contained in:
Chris Bednarski 2016-07-06 15:27:57 -07:00 committed by GitHub
commit 664e640257

View File

@ -20,6 +20,7 @@ import (
"strconv"
"strings"
"sync"
"unicode"
"golang.org/x/crypto/ssh"
@ -329,12 +330,21 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, pri
wg := sync.WaitGroup{}
repeat := func(r io.ReadCloser) {
scanner := bufio.NewScanner(r)
for scanner.Scan() {
ui.Message(scanner.Text())
}
if err := scanner.Err(); err != nil {
ui.Error(err.Error())
reader := bufio.NewReader(r)
for {
line, err := reader.ReadString('\n')
if line != "" {
line = strings.TrimRightFunc(line, unicode.IsSpace)
ui.Message(line)
}
if err != nil {
if err == io.EOF {
break
} else {
ui.Error(err.Error())
break
}
}
}
wg.Done()
}