Merge pull request #2942 from dave2/shell_noclean
Add "skip_clean" boolean to shell provisioner.
This commit is contained in:
commit
e9be2cff2b
|
@ -58,6 +58,9 @@ type Config struct {
|
||||||
// This can be set high to allow for reboots.
|
// This can be set high to allow for reboots.
|
||||||
RawStartRetryTimeout string `mapstructure:"start_retry_timeout"`
|
RawStartRetryTimeout string `mapstructure:"start_retry_timeout"`
|
||||||
|
|
||||||
|
// Whether to clean scripts up
|
||||||
|
SkipClean bool `mapstructure:"skip_clean"`
|
||||||
|
|
||||||
startRetryTimeout time.Duration
|
startRetryTimeout time.Duration
|
||||||
ctx interpolate.Context
|
ctx interpolate.Context
|
||||||
}
|
}
|
||||||
|
@ -271,29 +274,32 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||||
return fmt.Errorf("Script exited with non-zero exit status: %d", cmd.ExitStatus)
|
return fmt.Errorf("Script exited with non-zero exit status: %d", cmd.ExitStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the temporary file we created. We retry this a few times
|
if !p.config.SkipClean {
|
||||||
// since if the above rebooted we have to wait until the reboot
|
|
||||||
// completes.
|
|
||||||
err = p.retryable(func() error {
|
|
||||||
cmd = &packer.RemoteCmd{
|
|
||||||
Command: fmt.Sprintf("rm -f %s", p.config.RemotePath),
|
|
||||||
}
|
|
||||||
if err := comm.Start(cmd); err != nil {
|
|
||||||
return fmt.Errorf(
|
|
||||||
"Error removing temporary script at %s: %s",
|
|
||||||
p.config.RemotePath, err)
|
|
||||||
}
|
|
||||||
cmd.Wait()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if cmd.ExitStatus != 0 {
|
// Delete the temporary file we created. We retry this a few times
|
||||||
return fmt.Errorf(
|
// since if the above rebooted we have to wait until the reboot
|
||||||
"Error removing temporary script at %s!",
|
// completes.
|
||||||
p.config.RemotePath)
|
err = p.retryable(func() error {
|
||||||
|
cmd = &packer.RemoteCmd{
|
||||||
|
Command: fmt.Sprintf("rm -f %s", p.config.RemotePath),
|
||||||
|
}
|
||||||
|
if err := comm.Start(cmd); err != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"Error removing temporary script at %s: %s",
|
||||||
|
p.config.RemotePath, err)
|
||||||
|
}
|
||||||
|
cmd.Wait()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.ExitStatus != 0 {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"Error removing temporary script at %s!",
|
||||||
|
p.config.RemotePath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,10 @@ Optional parameters:
|
||||||
system reboot. Set this to a higher value if reboots take a longer amount
|
system reboot. Set this to a higher value if reboots take a longer amount
|
||||||
of time.
|
of time.
|
||||||
|
|
||||||
|
- `skip_clean` (boolean) - If true, specifies that the helper scripts
|
||||||
|
uploaded to the system will not be removed by Packer. This defaults to
|
||||||
|
false (clean scripts from the system).
|
||||||
|
|
||||||
## Execute Command Example
|
## Execute Command Example
|
||||||
|
|
||||||
To many new users, the `execute_command` is puzzling. However, it provides an
|
To many new users, the `execute_command` is puzzling. However, it provides an
|
||||||
|
|
Loading…
Reference in New Issue