[chef] conditional in recipe to evaluate node name not working (as expected)


Chronological Thread 
  • From: Jeremy Koerber < >
  • To:
  • Subject: [chef] conditional in recipe to evaluate node name not working (as expected)
  • Date: Thu, 14 Mar 2013 11:14:14 -0700

Hi,
I’m trying to modify the community memcached recipe such that it will source one template file if the node name starts with qa, and another if the node name is anything else. But no matter what I try, the recipe seems to ignore the conditional and just goes with the “else” block. So the result is that my nodes that are named qa* are getting my production template sourced. I even tried just setting the node name conditional to the exact name of a specific node, and still that node ends up with the default template, not the QA one specified in the conditional. Here’s the conditional:

case node["name"]
when "qa*"
 template "/opt/zookeeper/conf/zk.conf" do
  source "zk.qa.conf.erb"
  owner "root"
  group "root"
  mode "0644"
 end
else
 template "/opt/zookeeper/conf/zk.conf" do
  source "zk.prod.conf.erb"
  owner "root"
  group "root"
  mode "0644"
 end
end

I also have these nodes in a separate chef environment called “qa”, but I’m not having any luck keying off that either. Any ideas? Here’s the output of a ‘knife node show’ for the node in question:

knife node show -Fj qa-memcached01-1-i-91e11be3
{
  "name": "qa-memcached01-1-i-91e11be3",
  "chef_environment": "qa",
  "run_list": [
    "role[memcached]"
  ],
  "normal": {
    "memcached": {
      "memory": "384"
    },
    "tags": [

    ]
  }
}

Thanks, Jeremy



--
Jeremy Koerber
Director - Tech Ops






Archive powered by MHonArc 2.6.16.

§