[chef] Chef and find a json file generated from a previous recipe


Chronological Thread 
  • From: David Montgomery < >
  • To:
  • Subject: [chef] Chef and find a json file generated from a previous recipe
  • Date: Tue, 2 Jun 2015 12:44:34 +0800

Hi,

I have two recipes. 

The job of the first recipe is the run a python script and to save to disk a json file.

The job of the second recipe is to read the the json file into a hash and pass to a template.

Below is the second recipe


if File.exists?("#{Chef::Config[:file_cache_path]}/zookeeper_hosts")
    zookeeper_hosts = File.read("#{Chef::Config[:file_cache_path]}/zookeeper_hosts")
end

template "/etc/zookeeper/conf/zoo.cfg" do
  path "/etc/zookeeper/conf/zoo.cfg"
  source "cloudera.zoo.cfg.erb"
  owner "root"
  group "root"
  mode "0644"
  variables :zookeeper => zookeeper_hosts
  notifies :restart, resources(:service => "zookeeper-server")
end


On the first run of chef, all works but the zookeeper_hosts is Null.  If I rerun chef after the intial run then zookeeper_hosts has the proper hash even though the previous run generated the hash.


How can I load the json file generated from json created from a previous recipe?

Thanks
















Archive powered by MHonArc 2.6.16.

§