On Tuesday, September 3, 2013 at 2:42 PM, wrote:
Hiya,I'm creating an internal CI service for my group, and there's this bit I'mtrying to implement, but it's not working yet. I'm hoping someone could providetips. It is possible I'm going about this in an anti-pattern way. Feedbackappreciated:When a "worker" node is launched (ec2), a master CI node waits for the workernode to finish running chef and become ready to take commands from the master CInode. My idea is, the master CI node polls the chef API looking for a certainnode attribute of this particular worker node.On the worker node, in the first chef run, I want to have it set for itself anattribute that indicates it's "ready". If it's not ready, it's "pending". Fornow, let's just say node's readiness is satisfied if mysql is running. If it'srunning, the node should set this attr within the recipe:node.set['macabre']['salad']['bacon']['state'] = "ready"But I'm failing at getting the node to set this correctly.This code below was my first try, but it doesn't work at all in that it falselysets "ready" every chef run, regardless if mysql is running or not. Should thiswork the way I've written it?# This is falsely setting "ready" every timeif `/sbin/pidof mysql >/dev/null 2>&1`
Chef::Log.debug("HIGGS-BOSON: setting bacon state ready")node.set['macabre']['salad']['bacon']['state'] = "ready"elseChef::Log.debug("HIGGS-BOSON: setting bacon state pending")node.set['macabre']['salad']['bacon']['state'] = "pending"endAnd here's my second try. It's failing in that it takes 2 chef client runs toactually get the correct state reported: if current node attr state is "ready",I stop mysql, then run chef again, the state gets set to "ready" again. But upona second chef run, with mysql still stopped, the state correctly gets set to"pending". When I see this kind of thing happening, it tells me I need to thinkabout the chef client run in compile time vs run time. I tried the following,but it takes 2 chef client runs to see the correct state:e = execute "is mysql running" doaction :nothingcommand "sleep 0"user "root"pidfile="/var/lib/mysql/#{node['fqdn']}.pid"if File.exists?("#{pidfile}")Chef::Log.debug("HIGGS-BOSON: setting bacon state ready. pidfile: #{pidfile}")node.set['macabre']['salad']['bacon']['state'] = "ready"elseChef::Log.debug("HIGGS-BOSON: setting bacon state pending")node.set['macabre']['salad']['bacon']['state'] = "pending"endende.run_action(:run)
So, yeah. Any advice?TIA,kallen
Archive powered by MHonArc 2.6.16.