Wait for corosync to be ready before doing anything

On the initial run, it takes 20-30 seconds before corosync is ready to
accept changes with "crm configure". So wait for that before we continue
(and apply crm-initial.conf, for instance).
This commit is contained in:
Vincent Untz 2014-03-26 09:23:44 +01:00
parent 4915a3dd62
commit 3e04b36985
1 changed files with 18 additions and 0 deletions

View File

@ -49,6 +49,24 @@ else
include_recipe "corosync::default"
end
ruby_block "wait for cluster to be online" do
block do
require 'timeout'
begin
Timeout.timeout(60) do
cmd = "crm_mon -1 | grep -qi online"
while ! ::Kernel.system(cmd)
Chef::Log.debug("cluster not online yet")
sleep(5)
end
end
rescue Timeout::Error
message = "Pacemaker cluster not online yet; our first configuration changes might get lost (but will be reapplied on next chef run)."
Chef::Log.warn(message)
end
end # block
end # ruby_block
if node[:pacemaker][:founder]
include_recipe "pacemaker::setup"
end