Merge pull request #2254 from marc-ta/vmxdisktemplatepath
Vmware iso: Add vmx disk template path for builder
This commit is contained in:
commit
649f0f34fc
1
builder/vmware/iso/builder.go
Normal file → Executable file
1
builder/vmware/iso/builder.go
Normal file → Executable file
@ -50,6 +50,7 @@ type Config struct {
|
||||
BootCommand []string `mapstructure:"boot_command"`
|
||||
SkipCompaction bool `mapstructure:"skip_compaction"`
|
||||
VMXTemplatePath string `mapstructure:"vmx_template_path"`
|
||||
VMXDiskTemplatePath string `mapstructure:"vmx_disk_template_path"`
|
||||
|
||||
RemoteType string `mapstructure:"remote_type"`
|
||||
RemoteDatastore string `mapstructure:"remote_datastore"`
|
||||
|
26
builder/vmware/iso/step_create_vmx.go
Normal file → Executable file
26
builder/vmware/iso/step_create_vmx.go
Normal file → Executable file
@ -76,7 +76,29 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction {
|
||||
DiskName: config.DiskName,
|
||||
}
|
||||
|
||||
diskTemplate, err := interpolate.Render(DefaultAdditionalDiskTemplate, &ctx)
|
||||
diskTemplate := DefaultAdditionalDiskTemplate
|
||||
if config.VMXDiskTemplatePath != "" {
|
||||
f, err := os.Open(config.VMXDiskTemplatePath)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error reading VMX disk template: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
rawBytes, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error reading VMX disk template: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
diskTemplate = string(rawBytes)
|
||||
}
|
||||
|
||||
diskContents, err := interpolate.Render(diskTemplate, &ctx)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error preparing VMX template for additional disk: %s", err)
|
||||
state.Put("error", err)
|
||||
@ -84,7 +106,7 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction {
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
vmxTemplate += diskTemplate
|
||||
vmxTemplate += diskContents
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user