Allow skipping Chef Client staging directory cleanup (fixes #3151).

This commit is contained in:
Don Luchini 2016-12-19 15:16:37 -05:00 committed by don-code
parent fefaf0fa61
commit edb845b3f4
1 changed files with 5 additions and 2 deletions

View File

@ -63,6 +63,7 @@ type Config struct {
ServerUrl string `mapstructure:"server_url"` ServerUrl string `mapstructure:"server_url"`
SkipCleanClient bool `mapstructure:"skip_clean_client"` SkipCleanClient bool `mapstructure:"skip_clean_client"`
SkipCleanNode bool `mapstructure:"skip_clean_node"` SkipCleanNode bool `mapstructure:"skip_clean_node"`
SkipCleanStagingDirectory bool `mapstructure:"skip_clean_staging_directory"`
SkipInstall bool `mapstructure:"skip_install"` SkipInstall bool `mapstructure:"skip_install"`
SslVerifyMode string `mapstructure:"ssl_verify_mode"` SslVerifyMode string `mapstructure:"ssl_verify_mode"`
TrustedCertsDir string `mapstructure:"trusted_certs_dir"` TrustedCertsDir string `mapstructure:"trusted_certs_dir"`
@ -319,9 +320,11 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
return fmt.Errorf("Error executing Chef: %s", err) return fmt.Errorf("Error executing Chef: %s", err)
} }
if !p.config.SkipCleanStagingDirectory {
if err := p.removeDir(ui, comm, p.config.StagingDir); err != nil { if err := p.removeDir(ui, comm, p.config.StagingDir); err != nil {
return fmt.Errorf("Error removing %s: %s", p.config.StagingDir, err) return fmt.Errorf("Error removing %s: %s", p.config.StagingDir, err)
} }
}
return nil return nil
} }