Linux has uptime command I think it`s the best way to indicate reboot happened.I hope, it will help.2015-01-12 11:17 GMT+02:00 Sachin Gupta < " target="_blank"> >:Hi All,I will be calling linux_reboot once there is an kernel update.
I have an use case where I need to reboot the machine if there is any new kernel update/install.
I am trying to write an LWRP for reboot handler that can be used in other recipe's also.
added this code in recipe for reboot:;
linux_reboot 'kernel updated' do
action :reboot
end
----------------------------------------------------
resource/reboot.rb
------------------------------------------------------
actions :reboot
default_action :reboot
attribute :happened, kind_of: String
attr_accessor :exists
-----------------------------------------------------------
provider/reboot.rb
------------------------------------------------------
def whyrun_supported?
true
end
action :reboot do
Chef::Log.info "=== Cookbook: #{cookbook_name}"
Chef::Log.info "=== Resource Name: #{@new_resource.name}"
if @current_resource.happened
Chef::Log.info 'Reboot happened'
else
converge_by("Reboot system") do
reboot
end
end
end
def load_current_resource
@current_resource = Chef::Resource::linuxReboot.new(@new_resource.name)
@current_resource.happened = false
begin# search for a file and set the flag..end
Chef::Log.debug "Reboot debug message"
@current_resource
end
def reboot
Chef::Log.info 'Reboot The Machine'
end
------------------------------------------------------------------------------
what is the best way to indicate a reboot happened. shall I look for a file indicating a reboot or something else??
I am thinking to search for a file and if the reboot happened then set happened=true and return. will this work and is the right approach??
Thanks & Regards,
Sachin Kumar
PRIVILEGED AND CONFIDENTIAL COMMUNICATIONThis e-mail transmission, and any documents, files or previous e-mail messagesattached to it, may contain confidential information that is legally privileged.If you are not the intended recipient or a person responsible for delivering itto the intended recipient, you are hereby notified that any disclosure, copying,distribution or use of any of the information contained in or attached to thistransmission is strictly prohibited.If you have received this transmission in error, please: (1) immediately notifyme by reply e-mail, or by collect telephone call; and (2) destroy the originaltransmission and its attachments without reading or saving in any manner.
Archive powered by MHonArc 2.6.16.