Merge pull request #4472 from mitchellh/ansiblerandom

provisioner/anisble: use randomized staging dir
This commit is contained in:
Matthew Hooker 2017-02-09 20:50:32 -08:00 committed by GitHub
commit 45643d3885
2 changed files with 7 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import (
"strings"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
@ -85,7 +86,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
}
if p.config.StagingDir == "" {
p.config.StagingDir = DefaultStagingDir
p.config.StagingDir = filepath.Join(DefaultStagingDir, uuid.TimeOrderedUUID())
}
// Validation

View File

@ -1,10 +1,13 @@
package ansiblelocal
import (
"github.com/mitchellh/packer/packer"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"github.com/mitchellh/packer/packer"
)
func testConfig() map[string]interface{} {
@ -36,7 +39,7 @@ func TestProvisionerPrepare_Defaults(t *testing.T) {
t.Fatalf("err: %s", err)
}
if p.config.StagingDir != DefaultStagingDir {
if !strings.HasPrefix(filepath.ToSlash(p.config.StagingDir), DefaultStagingDir) {
t.Fatalf("unexpected staging dir %s, expected %s",
p.config.StagingDir, DefaultStagingDir)
}