From 441941b5538428f4f6cc93a67ba07c4f89655003 Mon Sep 17 00:00:00 2001 From: Andreas Kurz Date: Thu, 30 Aug 2018 15:08:46 +0200 Subject: [PATCH 1/2] provisioner_config: add skip_install parameter - allows to skip chef-client installation --- chefsolo/provisioner_config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chefsolo/provisioner_config.go b/chefsolo/provisioner_config.go index fd1d153..04c2ccd 100755 --- a/chefsolo/provisioner_config.go +++ b/chefsolo/provisioner_config.go @@ -115,9 +115,10 @@ func Provisioner() terraform.ResourceProvisioner { Type: schema.TypeString, Optional: true, }, - "recreate_client": { + "skip_install": { Type: schema.TypeBool, Optional: true, + Default: false, }, "prevent_sudo": { Type: schema.TypeBool, @@ -178,6 +179,7 @@ func configureProvisioner(d *schema.ResourceData, osType afero.Fs) (*provisioner ClientOptions: getStringList(d.Get("client_options")), Environment: d.Get("environment").(string), UsePolicyfile: d.Get("use_policyfile").(bool), + SkipInstall: d.Get("skip_install").(bool), HTTPProxy: d.Get("http_proxy").(string), HTTPSProxy: d.Get("https_proxy").(string), NOProxy: getStringList(d.Get("no_proxy")), From 5d4e76e93c6e23b2e2e6a0464b08d098692ddf3d Mon Sep 17 00:00:00 2001 From: Andreas Kurz Date: Thu, 30 Aug 2018 15:10:11 +0200 Subject: [PATCH 2/2] provisioner_utils: fix getCommunicator to allow stable ssh connections (like remote-exec provisioner) --- chefsolo/provisioner_utils.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/chefsolo/provisioner_utils.go b/chefsolo/provisioner_utils.go index cd65c0a..a0dc3a4 100755 --- a/chefsolo/provisioner_utils.go +++ b/chefsolo/provisioner_utils.go @@ -42,6 +42,12 @@ func getCommunicator(ctx context.Context, o terraform.UIOutput, s *terraform.Ins if err != nil { return nil, err } - defer comm.Disconnect() + + // Wait for the context to end and then disconnect + go func() { + <-ctx.Done() + comm.Disconnect() + }() + return comm, err }