Skip to content

Commit 5a9ebb8

Browse files
committed
Allow RFC062 Exit Codes
Signed-off-by: Brian Dwyer <Brian.Dwyer@broadridge.com>
1 parent d47f984 commit 5a9ebb8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

builtin/provisioners/chef/resource_provisioner.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,22 @@ func (p *provisioner) runCommand(o terraform.UIOutput, comm communicator.Communi
703703
}
704704

705705
if err := cmd.Wait(); err != nil {
706-
return err
706+
// Allow RFC062 Exit Codes
707+
// https://github.com/chef/chef-rfc/blob/master/rfc062-exit-status.md
708+
exitError, ok := err.(*remote.ExitError)
709+
if !ok {
710+
return fmt.Errorf("Expected remote.ExitError but got: %w", err)
711+
}
712+
switch exitError.ExitStatus {
713+
case 35:
714+
o.Output("Reboot has been scheduled in the run state")
715+
case 37:
716+
o.Output("Reboot needs to be completed")
717+
case 213:
718+
o.Output("Chef has exited during a client upgrade")
719+
default:
720+
return err
721+
}
707722
}
708723

709724
return nil

0 commit comments

Comments
 (0)