Node name not being used for cookbook_file file specificity with chef-solo


#1

'm working on managing some hosts on a remote network using chef-solo. In a
cookbook recipe, I’m trying to push out a host-specific configuration file
using file specificity and was surprised that a cookbook_file resource
wasn’t getting the nodename specific file location.

The traceback from the cookbook file:
[vagrant@localhost:2222] out: cookbook_file[redacted_path/intelfilter]
(redacted_cookbook) had an error: Chef::Exceptions::FileNotFound: Cookbook
’redacted_cookbook’ (0.0.1) does not contain a file at any of these
locations:
[vagrant@localhost:2222] out: files/ubuntu-10.04/intelfilter
[vagrant@localhost:2222] out: files/ubuntu/intelfilter
[vagrant@localhost:2222] out: files/default/intelfilter

ohai for this host (a basic vagrant vm) shows:
“hostname”: “lucid32”,
“fqdn”: “lucid32”,
“domain”: null,

My files hierarchy for my cookbook has:
files/lucid32/intelfilter

My node.json has just the run_list:
{“run_list”: [“role[redacted_role]”]}

And my solo.rb has:
log_level :info
log_location STDOUT
file_cache_path "/var/chef-solo"
cookbook_path [ “/var/chef-solo/cookbooks” ]
role_path "/var/chef-solo/roles"
Chef::Log::Formatter.show_time = true

I know I could put an explicit node_name declaration in solo.rb; however,
the documentation states:

The default value is set automatically to the fully qualified domain name
(fqdn) as detected by Ohai.

Since the solo.rb is shared across multiple hosts, and the ohai for this
node is correct (or at least, the output is accounted for), why is
chef-solo not finding (or apparently even looking for) the node-specific
files? It’s obviously looked at ohai output, since the files that were
searched include the platform of the host, but not the node_name/fqdn.

Any help would be very much appreciated.

– William


#2

Hello,

On Tue, May 22, 2012 at 3:34 PM, William McVey wam-chef@wamber.net wrote:

'm working on managing some hosts on a remote network using chef-solo. In a
cookbook recipe, I’m trying to push out a host-specific configuration file
using file specificity and was surprised that a cookbook_file resource
wasn’t getting the nodename specific file location.

The node name is not used, the FQDN is. The per-host directories
should be named “host-FQDN-of-node”. For example, if your managed
node’s FQDN is “lucid32.example.com”, then this path to the file
source you want to manage in your cookbook would be:

cookbooks/redacted/files/host-lucid32.example.com/inetfilter


Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman