Merge pull request #5085 from Lee303/builder-hyperv-temppath
Hyper-V Builder - Add support for temp_path directive to override system %temp%
This commit is contained in:
commit
2325c1ee58
|
@ -2,13 +2,15 @@ package common
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type StepCreateTempDir struct {
|
||||
TempPath string
|
||||
dirPath string
|
||||
}
|
||||
|
||||
|
@ -17,8 +19,11 @@ func (s *StepCreateTempDir) Run(state multistep.StateBag) multistep.StepAction {
|
|||
|
||||
ui.Say("Creating temporary directory...")
|
||||
|
||||
tempDir := os.TempDir()
|
||||
packerTempDir, err := ioutil.TempDir(tempDir, "packerhv")
|
||||
if s.TempPath == "" {
|
||||
s.TempPath = os.TempDir()
|
||||
}
|
||||
|
||||
packerTempDir, err := ioutil.TempDir(s.TempPath, "packerhv")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error creating temporary directory: %s", err)
|
||||
state.Put("error", err)
|
||||
|
|
|
@ -80,6 +80,7 @@ type Config struct {
|
|||
EnableDynamicMemory bool `mapstructure:"enable_dynamic_memory"`
|
||||
EnableSecureBoot bool `mapstructure:"enable_secure_boot"`
|
||||
EnableVirtualizationExtensions bool `mapstructure:"enable_virtualization_extensions"`
|
||||
TempPath string `mapstructure:"temp_path"`
|
||||
|
||||
Communicator string `mapstructure:"communicator"`
|
||||
|
||||
|
@ -293,7 +294,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
state.Put("ui", ui)
|
||||
|
||||
steps := []multistep.Step{
|
||||
&hypervcommon.StepCreateTempDir{},
|
||||
&hypervcommon.StepCreateTempDir{
|
||||
TempPath: b.config.TempPath,
|
||||
},
|
||||
&hypervcommon.StepOutputDir{
|
||||
Force: b.config.PackerForce,
|
||||
Path: b.config.OutputDir,
|
||||
|
|
|
@ -205,6 +205,9 @@ can be configured for this builder.
|
|||
machine, without the file extension. By default this is "packer-BUILDNAME",
|
||||
where "BUILDNAME" is the name of the build.
|
||||
|
||||
- `temp_path` (string) - This is the temporary path in which Packer will create the virtual
|
||||
machine. Default value is system `%temp%`
|
||||
|
||||
## Boot Command
|
||||
|
||||
The `boot_command` configuration is very important: it specifies the keys
|
||||
|
|
Loading…
Reference in New Issue