mirror of
https://github.com/hashicorp/packer.git
synced 2026-04-27 00:59:18 -04:00
bugfix and some debug logging
This commit is contained in:
parent
00ff187d77
commit
ca3bffcb0d
4 changed files with 36 additions and 2 deletions
|
|
@ -76,13 +76,12 @@ func (s *stepCreatePVBuilder) Cleanup(state multistep.StateBag) {
|
|||
// terminate instance
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
client := state.Get("client").(*compute.ComputeClient)
|
||||
config := state.Get("config").(*Config)
|
||||
|
||||
ui.Say("Terminating builder instance...")
|
||||
|
||||
instanceClient := client.Instances()
|
||||
input := &compute.DeleteInstanceInput{
|
||||
Name: config.ImageName,
|
||||
Name: s.name,
|
||||
ID: instanceID.(string),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,4 +63,35 @@ func (s *stepCreatePVMaster) Run(_ context.Context, state multistep.StateBag) mu
|
|||
}
|
||||
|
||||
func (s *stepCreatePVMaster) Cleanup(state multistep.StateBag) {
|
||||
_, deleted := state.GetOk("master_instance_deleted")
|
||||
if deleted {
|
||||
return
|
||||
}
|
||||
|
||||
instanceID, ok := state.GetOk("master_instance_id")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// terminate instance
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
client := state.Get("client").(*compute.ComputeClient)
|
||||
|
||||
ui.Say("Terminating builder instance...")
|
||||
|
||||
instanceClient := client.Instances()
|
||||
input := &compute.DeleteInstanceInput{
|
||||
Name: s.name,
|
||||
ID: instanceID.(string),
|
||||
}
|
||||
|
||||
err := instanceClient.DeleteInstance(input)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Problem destroying instance: %s", err)
|
||||
ui.Error(err.Error())
|
||||
state.Put("error", err)
|
||||
return
|
||||
}
|
||||
// TODO wait for instance state to change to deleted?
|
||||
ui.Say("Terminated master instance.")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package classic
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-oracle-terraform/compute"
|
||||
|
|
@ -30,6 +31,7 @@ func (s *stepSecurity) Run(_ context.Context, state multistep.StateBag) multiste
|
|||
runUUID := uuid.TimeOrderedUUID()
|
||||
|
||||
secListName := fmt.Sprintf("Packer_%s_Allow_%s_%s", commType, config.ImageName, runUUID)
|
||||
log.Println(secListName)
|
||||
secListClient := client.SecurityLists()
|
||||
secListInput := compute.CreateSecurityListInput{
|
||||
Description: fmt.Sprintf("Packer-generated security list to give packer %s access", commType),
|
||||
|
|
@ -73,6 +75,7 @@ func (s *stepSecurity) Run(_ context.Context, state multistep.StateBag) multiste
|
|||
secRulesClient := client.SecRules()
|
||||
secRuleName := fmt.Sprintf("Packer-allow-%s-Rule_%s_%s", commType,
|
||||
config.ImageName, runUUID)
|
||||
log.Println(secRuleName)
|
||||
secRulesInput := compute.CreateSecRuleInput{
|
||||
Action: "PERMIT",
|
||||
Application: application,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ func (s *stepTerminatePVMaster) Run(_ context.Context, state multistep.StateBag)
|
|||
}
|
||||
|
||||
ui.Message(fmt.Sprintf("Deleted master instance: %s.", instanceInfo.ID))
|
||||
state.Put("master_instance_deleted", true)
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue