diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index 1fb2d4bc6..e3dd4dd77 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -163,6 +163,17 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } } + if p.config.ManifestDir != "" { + info, err := os.Stat(p.config.ManifestDir) + if err != nil { + errs = packer.MultiErrorAppend(errs, + fmt.Errorf("manifest_dir is invalid: %s", err)) + } else if !info.IsDir() { + errs = packer.MultiErrorAppend(errs, + fmt.Errorf("manifest_dir must point to a directory")) + } + } + if p.config.ManifestFile == "" { errs = packer.MultiErrorAppend(errs, fmt.Errorf("A manifest_file must be specified.")) diff --git a/provisioner/puppet-masterless/provisioner_test.go b/provisioner/puppet-masterless/provisioner_test.go index b71534aea..0d5576b6b 100644 --- a/provisioner/puppet-masterless/provisioner_test.go +++ b/provisioner/puppet-masterless/provisioner_test.go @@ -87,13 +87,13 @@ func TestProvisionerPrepare_manifestDir(t *testing.T) { } // Test with a good one - tf, err := ioutil.TempFile("", "packer") + td, err := ioutil.TempDir("", "packer") if err != nil { - t.Fatalf("error tempfile: %s", err) + t.Fatalf("error: %s", err) } - defer os.Remove(tf.Name()) + defer os.RemoveAll(td) - config["manifest_dir"] = tf.Name() + config["manifest_dir"] = td p = new(Provisioner) err = p.Prepare(config) if err != nil {