[chef] Re: compile vs execution phase


Chronological Thread 
  • From: Sean OMeara < >
  • To:
  • Subject: [chef] Re: compile vs execution phase
  • Date: Mon, 6 Jan 2014 10:03:15 -0500

This problem comes up almost every day for me.
What needs to happen is.. recipe A needs to converge before recipe B compiles.

You can manually manipulate run_contexts if you're brave enough to go mucking around in Chef internals..

or...

There is a library cookbook called "now" on the community site that provides a hack for you.

Check out the integration tests for a usage example

-s



On Sat, Jan 4, 2014 at 12:46 AM, Bill Warner < " target="_blank"> > wrote:
I've been working on learning how to write cookbooks using chef-solo.  I have created two cookbooks, one that evaluates the physical array controllers and configures, partitions, luks_encrypts, mkfs and mounts the drives to /data/1, /data/2, /data/3, etc...  This works really well on a new machine and puts the hardware in a state we are looking for no matter how many drives there are or what their sizes are.

I also have a simple cassandra cookbook that installs an fpm version of cassandra, runs a template of the cassandra.yaml and creates the data directories depending on what drives are mounted to /data/1 /data/2 /data/3 etc...
done similar to:

#attributes file
default[:datadirs] = []
Dir.foreach("/data") do |drives|
  next if drives.match(/^\.\.?$)
  if system "/bin/mountpoint /data/#{drives}>/dev/null" then
    default[:cassandra][:data_dirs].push( "/data/#{drives}/cassandra/data" )
  end
end

#recipe
node[:cassandra][:data_dirs].each do |data_dir|
  directory "#{data_dir}" do
    owner "cassandra"
    group "cassandra"
    mode 0750
    action :create
    recursive true
  end
end


Of course this is getting generated at compile time when nothing is in /data.  The disks cookbook runs and populates /data/# however, the cassandra cookbook wont work unless there is a way to regen the recipe after the disk cookbook has completed.  running chef-solo a second time gets things into a proper state.

Is there a better way to create the directories?  I think I can use the lazy attribute assignment to make my template work, but the directory creation is giving me hell.

Thanks for any help
--
Bill Warner




Archive powered by MHonArc 2.6.16.

§