How to wait for machine to reboot in the middle of a recipe?

I have a bootstrap recipe that is supposed to rename the system and join domain and then requires a reboot in the middle of a recipe. I know that I will need to create a scheduled task or a service to let chef-client run on its own after reboot. Now I am putting this recipe in the machine resource itself so that bootstrapping starts after machine comes up. But as soon as the machine reboots in the middle of this recipe run, the machine converge gets completed with Error code 35. Reboot_Scheduled. Is there a way to make the provisioner node wait for the machine to reboot and then continue the converge?

I also see this message in the end
WARN: Per RFC 062 (, when a reboot is requested Chef Client will exit with an exit code of 35, REBOOT_SCHEDULED. To maintain the current behavior (an exit code of 0), you will need to set 'exit_status' to ':disabled' in your client.rb at C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.89-universal-mingw32/bin/chef-client:26:in '<top (required)>' at C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.89-universal-mingw32/lib/chef/event_dispatch/dispatcher.rb:43:in call

but if I put this line exit_status :disabled in provisioner node’s client.rb file it doesn’t make any difference.

How we can resolve the above issue?

The error is inconsequential and is just letting you know that the chef client did not run to it's normal completion. We reboot in the middle of the initial chef client execution during 2 types of servers that we build and we continue when the reboot completes.

If everything else is working correctly when you check the logs or better yet if you have Chef Automate you will see an error during the first chef client run followed by a run that completes successfully. We never figured out a way to suppress the error reporting and since we expect it and know what it means we don't bother with wasting any time on it.

You could utilize the reboot resource to request_reboot instead of reboot instantly. That will queue the reboot to the end of the client run.

Note: specifically for things like domain joins, etc you should guard other resources further in the resource collection with not_if pending_reboot?

This may still result in an error in your provisioner as it still doesn't handle the reboot cleanly. But as Joe stated, its not really an error in the sense of the word.