I have created cookbook for enabling some of the windows feature and rebooting the machine using WindowsRebootHandler. As shown in below code, I have used ruby_block to not perform the same action in the subsequent runs.
windows_batch 'Enable_MS_Feature' do
code <<-EOH
#My script
EOH
notifies :create, "ruby_block[WindowsFeature_Install]", :immediately
notifies :request, 'windows_reboot[60]'
not_if { node.attribute?("WindowsFeature_Installed") }
end
ruby_block "WindowsFeature_Install" do
block do
node.set['WindowsFeature_Installed'] = true
node.save
end
action :nothing
end
For testing purpose, I have to delete WindowsFeature_Installed attribute to perform the action again. So, I have used below command.
knife exec -E "nodes.transform(:all) {|n| n.delete('WindowsFeature_Installed');n.save() }"
Above command is not deleting the node attribute. When I searched for the same attribute using knife command, it listed all the nodes.
knife search node "WindowsFeature_Installed:true"
To debug further, have enabled verbose output of the commands and all the HTTP responses from chef-server were OK.
Also, tried to check chef-server logs for error details. But was not able to identify the issue as many process logs are present related to chef-server package.
So, how can I remove this attribute to perform the recipe action again? Or in which chef-server log, node attribute delete details will be logged? Any pointers will be helpful.
n.set['WindowsFeature_Installed']=nilinstead ofn.delete('WindowsFeature_Installed'). - Draco Atern.setand was able to perform the recipe action again.knife exec -E "nodes.transform(:all) {|n| n.set['WindowsFeature_Installed']=false;n.save }". But, I am wondering whyn.deleteis failing. - vareda