Newbie needs help with why attributes are not shared between cookbooks


A bit of a background first. I am using chef from the eHMP (electronic medical record thing) repositories. It turns out that how they use Chef is a bit different from the official tutorial. Essentially everything is chef-client -z to execute cookbooks locally using a specific knife.rb which provides the location of the cookbooks.

I have to use chefdk version 0.18.30. (Aside: I am a bit aghast by how backwards incompatibility is not considered important in the Ruby world. I tried newer version and I get odd errors which were not previously present.)

The repo is here:

My problem is illustrated by this commit:

I have to manually set default[:nexus_url] and default[:workstation][:user_home] because they are not making it across from the cookbooks that have been invoked earlier that are calling the current cookbook that’s having the problem.

I don’t want to confuse people trying to help me here, so let’s focus on the simpler of the two: the user_home:

My command is:
sudo chef-client -o workstation --config /home/sam/Projects/vistacore/.chef/knife.rb

chef-repo/project_cookbooks/workstation/attributes/default.rb has this line in it:

default[:workstation][:user_home] = ENV["HOME"]

The workstation default recipe calls a wrapper recipe that then calls another recipe whose attributes rely on user_home being defined. And it’s not there.

Here’s what I tried to fix this:

  1. Add a dependency on the workstation cookbook in metadata.rb.
  2. Add an explicit call to set a specific value by including a recipe–e.g. include “common::load_nexus_url” (doesn’t apply to this example, but applies to the nexus_url example).

Nothing works!

Yet, somehow, it works elsewhere! I am very confused.

Hope I didn’t confuse you–Chef is very confusing.