3ofcoins / chef-helpers

A collection of helper methods to use in Opscode Chef recipes
MIT License
6 stars 3 forks source link

am i using try_templates() correctly? #5

Open brianjmurrell opened 8 years ago

brianjmurrell commented 8 years ago

I have:

template "/etc/cobbler/zone_templates/#{zone}" do
  source try_templates(["#{zone}.erb", "generic.erb"])
  mode 0644
  variables(:cobbler => node[:config][:cobbler],
            :config => node[:config],
            :ipa_ips => ipa_ips,
            :static_entries => static_entries)
    notifies :run, resources(:execute => "cobbler_sync")
  end
end

when there is no #{zone}.erb template file but there is a generic.erb template file.

I am getting the error:

Chef::Exceptions::FileNotFound
------------------------------
Cookbook 'cobbler' (0.0.1) does not contain a file at any of these locations:
  templates/centos-7.1.1503/example.com.erb
  templates/centos/example.com.erb
  templates/default/example.com.erb

when the value of zone is example.com.

I would have thought that because the `example.com.erb template file didn't exist it would be skipped over and generic.erb would have been used.

brianjmurrell commented 8 years ago

Anything on this? It seems like a pretty simple question which I would think should only take a couple of minutes to provide some assistance on please.

brianjmurrell commented 8 years ago

Has this project been abandoned?

mpasternacki commented 8 years ago

It's not actively developed at the moment; apologies for the late response.

It should work as you expect, though – it may be a regression. With which version of Chef client are you experiencing the issues? This functionality has been developed with Chef client version 11, and I don't think I'm using this feature in any cookbook with Chef client 12 now, so I might not have noticed the regression.