From 45030e191947928e460b4c737e422904587af426 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Fri, 27 Jan 2017 16:14:31 -0800 Subject: [PATCH 1/3] provisioner/anisble: use randomized staging dir --- provisioner/ansible-local/provisioner.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 0f445dff07226c5b7fe1bca74ea593dde56dc5a0 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Fri, 3 Feb 2017 15:03:19 -0800 Subject: [PATCH 2/3] fix tests --- provisioner/ansible-local/provisioner_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/provisioner/ansible-local/provisioner_test.go b/provisioner/ansible-local/provisioner_test.go index 45ee1c6e3..656ab944d 100644 --- a/provisioner/ansible-local/provisioner_test.go +++ b/provisioner/ansible-local/provisioner_test.go @@ -1,10 +1,12 @@ package ansiblelocal import ( - "github.com/mitchellh/packer/packer" "io/ioutil" "os" + "strings" "testing" + + "github.com/mitchellh/packer/packer" ) func testConfig() map[string]interface{} { @@ -36,7 +38,7 @@ func TestProvisionerPrepare_Defaults(t *testing.T) { t.Fatalf("err: %s", err) } - if p.config.StagingDir != DefaultStagingDir { + if !strings.HasPrefix(p.config.StagingDir, DefaultStagingDir) { t.Fatalf("unexpected staging dir %s, expected %s", p.config.StagingDir, DefaultStagingDir) } From a836268490b2696d744ea229cdc2c460f5dddd3b Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Mon, 6 Feb 2017 11:29:39 -0800 Subject: [PATCH 3/3] fix test on windows --- provisioner/ansible-local/provisioner_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/provisioner/ansible-local/provisioner_test.go b/provisioner/ansible-local/provisioner_test.go index 656ab944d..236c6252a 100644 --- a/provisioner/ansible-local/provisioner_test.go +++ b/provisioner/ansible-local/provisioner_test.go @@ -3,6 +3,7 @@ package ansiblelocal import ( "io/ioutil" "os" + "path/filepath" "strings" "testing" @@ -38,7 +39,7 @@ func TestProvisionerPrepare_Defaults(t *testing.T) { t.Fatalf("err: %s", err) } - if !strings.HasPrefix(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) }