Red 5
Red 5

Reputation: 338

Ignoring all reboot requests in Chef

I'm building a pipeline using Packer and Chef. I have a bunch of 3rd party cookbooks in my chef run list, most of them request a restart. When this happens, the whole chef run stops and packer errors out and nukes the machine.

Is there a way to ignore all reboot requests during a chef run? I want to restart at the end of a run, not during it. The only solution I've seen so far is to edit the cookbook and comment out the reboot.

EDIT: I'm using the dotnetframework cookbook from github which is using the "reboot" resource.

Upvotes: 0

Views: 201

Answers (2)

coderanger
coderanger

Reputation: 54181

You can monkeypatch the reboot resource(s) to use the no-op provider:

Chef::Provider::Noop.provides(:reboot)
Chef::Provider::Noop.provides(:windows_reboot)

Upvotes: 1

JackChance
JackChance

Reputation: 520

There is no good way to globally catch all reboot requests and set them from immediate to delayed. Your two options are to either edit then maintain a private version of every 3rd party cookbook you rely on and have them set a global reboot flag that gets processed at the end of your converge or to override the reboot resource in the windows cookbook so that it sets a flag then process that flag at the end.

Both require making your own internal fork(s) and neither is a really great option. A better approach would be to ask why you need those 3rd party cookbooks and if you could instead write a more streamlined process yourself that handled reboots the way you require.

Upvotes: 1

Related Questions