From 2e0a051539ebd58f10913df42e203daab0aa3f26 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Jun 2013 17:54:57 -0700 Subject: [PATCH] builder/*: Fail if provisioning fails [GH-33] --- builder/amazonebs/step_provision.go | 5 ++++- builder/digitalocean/step_provision.go | 5 ++++- builder/virtualbox/step_provision.go | 5 ++++- builder/vmware/step_provision.go | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/builder/amazonebs/step_provision.go b/builder/amazonebs/step_provision.go index 6f46983d4..00f1a5540 100644 --- a/builder/amazonebs/step_provision.go +++ b/builder/amazonebs/step_provision.go @@ -14,7 +14,10 @@ func (*stepProvision) Run(state map[string]interface{}) multistep.StepAction { ui := state["ui"].(packer.Ui) log.Println("Running the provision hook") - hook.Run(packer.HookProvision, ui, comm, nil) + if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil { + state["error"] = err + return multistep.ActionHalt + } return multistep.ActionContinue } diff --git a/builder/digitalocean/step_provision.go b/builder/digitalocean/step_provision.go index f1e6c8f49..32ad75c56 100644 --- a/builder/digitalocean/step_provision.go +++ b/builder/digitalocean/step_provision.go @@ -14,7 +14,10 @@ func (*stepProvision) Run(state map[string]interface{}) multistep.StepAction { ui := state["ui"].(packer.Ui) log.Println("Running the provision hook") - hook.Run(packer.HookProvision, ui, comm, nil) + if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil { + state["error"] = err + return multistep.ActionHalt + } return multistep.ActionContinue } diff --git a/builder/virtualbox/step_provision.go b/builder/virtualbox/step_provision.go index f6bf0b97f..6eaef456f 100644 --- a/builder/virtualbox/step_provision.go +++ b/builder/virtualbox/step_provision.go @@ -14,7 +14,10 @@ func (*stepProvision) Run(state map[string]interface{}) multistep.StepAction { ui := state["ui"].(packer.Ui) log.Println("Running the provision hook") - hook.Run(packer.HookProvision, ui, comm, nil) + if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil { + state["error"] = err + return multistep.ActionHalt + } return multistep.ActionContinue } diff --git a/builder/vmware/step_provision.go b/builder/vmware/step_provision.go index 4f089d937..706d64e59 100644 --- a/builder/vmware/step_provision.go +++ b/builder/vmware/step_provision.go @@ -14,7 +14,10 @@ func (*stepProvision) Run(state map[string]interface{}) multistep.StepAction { ui := state["ui"].(packer.Ui) log.Println("Running the provision hook") - hook.Run(packer.HookProvision, ui, comm, nil) + if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil { + state["error"] = err + return multistep.ActionHalt + } return multistep.ActionContinue }