- From: <
>
- To:
- Subject: [chef] Re: Windows nodes requiring a reboot after feature installation
- Date: Wed, 6 Feb 2013 23:58:20 -0800 (PST)
Hi Adam,
3., applied across all relevant resource types, looks to be the cleaner &
saner
option, indeed, inasmuch as it would have Chef automatically handle reboot
requirements, removing the need to code around them.
In the meantime, a kludge we use is to wrap the code in an
attribute-controlled
conditional, with the feature/package install resource in a different branch
to
the post-install resources. A quick-and-dirty example:
include_recipe 'windows::reboot_handler'
node.default[:windows][:allow_pending_reboots] = false
if !node[:iis_installed]
windows_feature 'IIS-WebServerRole' do
action :install
notifies :request, 'windows_reboot[60]'
end
ruby_block 'set_iis_install_flag' do
block do
node.set[:iis_installed] = true
end
end
windows_reboot 60 do
reason 'IIS-WebServerRole installed.'
action :nothing
end
else
ruby_block 'post_install' do
block do
Chef::Log.info 'post-install code is now running'
end
end
end
dsp
------------------------
I'm running into this issue with Windows Server nodes and am hoping other
chefs
on this list can help:
A Windows node executes chef-client. The first resource in its collection is
a
windows_feature resource which installs a role which requires a reboot to
complete installation. dism.exe installs the role and returns 3010 indicating
the need for a reboot, which causes that resource to fail and ends the chef
run. chef-client will fail at this point every time it runs until the system
is rebooted. I could set ignore_failure on the resource to true, but the
second resource in the node's collection requires that the Windows role is
fully installed (i.e. the system has been rebooted) to complete successfully,
so it too will fail until the system is rebooted.
Some possible solutions I can see:
1. Ignore failure on resource #1 but them immediately notify a script resource
that restarts the system. This seems heavy-handed since it reboots the system
in the middle of the chef run. Also, there may be cases in which the feature
will install without requiring a reboot, and in these cases, the system will
be
rebooted unnecessarily. This is my current method of dealing with the
problem.
2. Modify the windows_feature provider by adding an "allow_reboot" attribute.
If "allow_reboot" is set to true, then it will call dism.exe without the
"/norestart" flag, so that dism can restart the system itself. This will only
reboot the system if the feature installation requires it, but it still
reboots
the system in the middle of the chef run.
3. Modify windows_feature to optionally raise an exception to stop the chef
run
if a reboot is required, and create an error handler that will reboot the
system on this type of exception. This seems cleaner but is perhaps overkill?
One might encounter this problem in other contexts as well. "windows_package"
springs to mind as another resource type where you may want to conditionally
trigger a system reboot before continuing with the rest of a chef run. Has
anyone discovered a good way to deal with this kind of situation?
--
Adam Mielke
System Engineer
University of Minnesota
- [chef] Re: Windows nodes requiring a reboot after feature installation, dominique.poulain, 02/06/2013
Archive powered by MHonArc 2.6.16.