From edb845b3f429cc07155e66ba65d05cddaad1d04c Mon Sep 17 00:00:00 2001 From: Don Luchini Date: Mon, 19 Dec 2016 15:16:37 -0500 Subject: [PATCH] Allow skipping Chef Client staging directory cleanup (fixes #3151). --- provisioner/chef-client/provisioner.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/provisioner/chef-client/provisioner.go b/provisioner/chef-client/provisioner.go index b0af8cbea..13575f731 100644 --- a/provisioner/chef-client/provisioner.go +++ b/provisioner/chef-client/provisioner.go @@ -63,6 +63,7 @@ type Config struct { ServerUrl string `mapstructure:"server_url"` SkipCleanClient bool `mapstructure:"skip_clean_client"` SkipCleanNode bool `mapstructure:"skip_clean_node"` + SkipCleanStagingDirectory bool `mapstructure:"skip_clean_staging_directory"` SkipInstall bool `mapstructure:"skip_install"` SslVerifyMode string `mapstructure:"ssl_verify_mode"` TrustedCertsDir string `mapstructure:"trusted_certs_dir"` @@ -319,8 +320,10 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { return fmt.Errorf("Error executing Chef: %s", err) } - if err := p.removeDir(ui, comm, p.config.StagingDir); err != nil { - return fmt.Errorf("Error removing %s: %s", p.config.StagingDir, err) + if !p.config.SkipCleanStagingDirectory { + if err := p.removeDir(ui, comm, p.config.StagingDir); err != nil { + return fmt.Errorf("Error removing %s: %s", p.config.StagingDir, err) + } } return nil