我有如下食谱
target = node['zookeeper']['override']['target']
remote_file target do
source node['zookeeper']['override']['url']
owner 'root'
group 'root'
mode '0644'
action :create_if_missing
end
ruby_block 'check_zookeeper_upgraded' do
block do
node.run_state['zookeeper_upgraded'] = File.readlink('/usr/lib/zookeeper/zookeeper.jar').equal?(target)
end
end
link '/usr/lib/zookeeper/zookeeper.jar' do
group 'root'
owner 'root'
to target
action :create
not_if { node.run_state['zookeeper_upgraded'] }
end
file '/usr/lib/zookeeper/zookeeper-3.4.8.jar' do
action :delete
only_if { ::File.exist? '/usr/lib/zookeeper/zookeeper-3.4.8.jar' }
end
file '/usr/lib/zookeeper/zookeeper-3.4.5-cdh5.15.0.jar' do
action :delete
only_if { ::File.exist? '/usr/lib/zookeeper/zookeeper-3.4.5-cdh5.15.0.jar' }
end
service 'zookeeper-server' do
provider Chef::Provider::Service::Upstart
action :restart
ignore_failure true
only_if { !node.run_state['zookeeper_upgraded'] && !::File.exist?('/etc/init/zookeeper-server.override')}
end
有人可以让我知道如何记录node.run_state['zookeeper_upgraded']
的值,以便我可以检查zookeeper-server
是否最终重新启动吗?