From 3e04b36985f2f14dccab129f0c5808859562f3e4 Mon Sep 17 00:00:00 2001 From: Vincent Untz Date: Wed, 26 Mar 2014 09:23:44 +0100 Subject: [PATCH] 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). --- recipes/default.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/recipes/default.rb b/recipes/default.rb index 3258f33..2aca330 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -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