diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go index fa4a8db23..23562ec9a 100644 --- a/provisioner/ansible-local/provisioner.go +++ b/provisioner/ansible-local/provisioner.go @@ -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 diff --git a/provisioner/ansible-local/provisioner_test.go b/provisioner/ansible-local/provisioner_test.go index 45ee1c6e3..236c6252a 100644 --- a/provisioner/ansible-local/provisioner_test.go +++ b/provisioner/ansible-local/provisioner_test.go @@ -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) }