diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index d61d4d44e..f129d8c79 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -240,6 +240,10 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C } hostSigner, err := newSigner(p.config.SSHHostKeyFile) + if err != nil { + return fmt.Errorf("error creating host signer: %s", err) + } + // Remove the private key file if len(k.privKeyFile) > 0 { defer os.Remove(k.privKeyFile) diff --git a/provisioner/inspec/provisioner.go b/provisioner/inspec/provisioner.go index 618802f9f..f9d52d36c 100644 --- a/provisioner/inspec/provisioner.go +++ b/provisioner/inspec/provisioner.go @@ -217,6 +217,10 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C } hostSigner, err := newSigner(p.config.SSHHostKeyFile) + if err != nil { + return fmt.Errorf("error creating host signer: %s", err) + } + // Remove the private key file if len(k.privKeyFile) > 0 { defer os.Remove(k.privKeyFile)