I want to override a template in a cookbook wrapper, but the template resource is defined in a provider and not in a recipe. I've been overriding templates in wrappers like this example http://syshero.org/post/67727745605/override-templates-from-third-party-cookbooks-on
include_recipe "rsyslog"
begin
t = resources(:template => "/etc/rsyslog.conf")
t.source "rsyslog.conf.erb"
t.cookbook "example"
rescue Chef::Exceptions::ResourceNotFound
Chef::Log.warn "could not find template /etc/rsyslog.conf to modify"
end
and that always works as expected.
The cookbook which has a config I'm trying to change is the git_user cookbook https://supermarket.chef.io/cookbooks/git_user
and the point I'm trying to change is in a provider https://github.com/lxmx/chef-git-user/blob/master/providers/default.rb#L30
trying to use the same format as I did for recipes doesn't appear to work?
include_recipe "git_user::data_bag"
def load_current_resource
@login = new_resource.login
@home = new_resource.home || (@login == 'root' ? '/root' : "/home/#{@login}")
end
begin
home = @home
r = resources(:template => "#{home}/.ssh/config")
r.cookbook "MY-git_user"
rescue Chef::Exceptions::ResourceNotFound
Chef::Log.warn "could not find MY-git_user::data_bag template to override!"
end