Using a template in a provider fails, because it looks for the template in the wrapper ! whats the solution?


#1

I have made a resource that has a “template” resource that creates a file.

this is in my provider’s action :create
#Create silent.xml file out of the template
template “#{Chef::Config[:file_cache_path]}/silent.xml” do
source 'silent.xml.erb’
owner new_resource.user
group new_resource.group
mode '0755’
end

I use this resource in another cookbook and it fails because it is trying
find the template’s .ERB file in the wrapper cookbook which is using the
resource…

what is the proper solution for this problem? should I use File resource
instead of template?

the error I get is :

[2015-02-13T12:39:43-05:00] ERROR:
cccis-weblogic[/tools/binaries/Middleware/wlserver_1036]
(medya-demo-machines::test_weblogic_lwrp line 3) had an error:
Chef::Exceptions::FileNotFound: template[/var/chef/cache/silent.xml]
(/var/chef/cache/cookbooks/cccis-weblogic/providers/default.rb line 48) had
an error: Chef::Exceptions::FileNotFound: Cookbook ‘medya-demo-machines’
(0.0.1) does not contain a file at any of these locations:

templates/redhat-7.0/silent.xml.erb

templates/redhat/silent.xml.erb

templates/default/silent.xml.erb

                                                templates/silent.xml.erb

#2

You can add the name of the cookbook to the template resource:

cookbook “cccis-weblogic”

On 13 Feb 2015, at 17:48, Medya medya.gh@gmail.com wrote:

I have made a resource that has a “template” resource that creates a file.

this is in my provider’s action :create
#Create silent.xml file out of the template
template “#{Chef::Config[:file_cache_path]}/silent.xml” do
source 'silent.xml.erb’
owner new_resource.user
group new_resource.group
mode '0755’
end

I use this resource in another cookbook and it fails because it is trying find the template’s .ERB file in the wrapper cookbook which is using the resource…

what is the proper solution for this problem? should I use File resource instead of template?

the error I get is :

                                              [2015-02-13T12:39:43-05:00] ERROR: cccis-weblogic[/tools/binaries/Middleware/wlserver_1036] (medya-demo-machines::test_weblogic_lwrp line 3) had an error: Chef::Exceptions::FileNotFound: template[/var/chef/cache/silent.xml] (/var/chef/cache/cookbooks/cccis-weblogic/providers/default.rb line 48) had an error: Chef::Exceptions::FileNotFound: Cookbook 'medya-demo-machines' (0.0.1) does not contain a file at any of these locations:

                                                templates/redhat-7.0/silent.xml.erb

                                                templates/redhat/silent.xml.erb

                                                templates/default/silent.xml.erb

                                                templates/silent.xml.erb

#3

how do I add a name to a template resource?

On Fri, Feb 13, 2015 at 12:03 PM, Kimball Johnson kimball@bowerham.net
wrote:

You can add the name of the cookbook to the template resource:

cookbook “cccis-weblogic”

On 13 Feb 2015, at 17:48, Medya medya.gh@gmail.com wrote:

I have made a resource that has a “template” resource that creates a
file.

this is in my provider’s action :create
#Create silent.xml file out of the template
template “#{Chef::Config[:file_cache_path]}/silent.xml” do
source 'silent.xml.erb’
owner new_resource.user
group new_resource.group
mode '0755’
end

I use this resource in another cookbook and it fails because it is
trying find the template’s .ERB file in the wrapper cookbook which is using
the resource…

what is the proper solution for this problem? should I use File resource
instead of template?

the error I get is :

[2015-02-13T12:39:43-05:00] ERROR:
cccis-weblogic[/tools/binaries/Middleware/wlserver_1036]
(medya-demo-machines::test_weblogic_lwrp line 3) had an error:
Chef::Exceptions::FileNotFound: template[/var/chef/cache/silent.xml]
(/var/chef/cache/cookbooks/cccis-weblogic/providers/default.rb line 48) had
an error: Chef::Exceptions::FileNotFound: Cookbook ‘medya-demo-machines’
(0.0.1) does not contain a file at any of these locations:

templates/redhat-7.0/silent.xml.erb

templates/redhat/silent.xml.erb

templates/default/silent.xml.erb

templates/silent.xml.erb


#4

Your template resource in your provider.

template “#{Chef::Config[:file_cache_path]}/silent.xml” do
cookbook "cccis-weblogic"
source 'silent.xml.erb’
owner new_resource.user

On Fri, Feb 13, 2015 at 11:13 AM, Medya medya.gh@gmail.com wrote:

how do I add a name to a template resource?

On Fri, Feb 13, 2015 at 12:03 PM, Kimball Johnson kimball@bowerham.net
wrote:

You can add the name of the cookbook to the template resource:

cookbook “cccis-weblogic”

On 13 Feb 2015, at 17:48, Medya medya.gh@gmail.com wrote:

I have made a resource that has a “template” resource that creates a
file.

this is in my provider’s action :create
#Create silent.xml file out of the template
template “#{Chef::Config[:file_cache_path]}/silent.xml” do
source 'silent.xml.erb’
owner new_resource.user
group new_resource.group
mode '0755’
end

I use this resource in another cookbook and it fails because it is
trying find the template’s .ERB file in the wrapper cookbook which is using
the resource…

what is the proper solution for this problem? should I use File
resource instead of template?

the error I get is :

[2015-02-13T12:39:43-05:00] ERROR:
cccis-weblogic[/tools/binaries/Middleware/wlserver_1036]
(medya-demo-machines::test_weblogic_lwrp line 3) had an error:
Chef::Exceptions::FileNotFound: template[/var/chef/cache/silent.xml]
(/var/chef/cache/cookbooks/cccis-weblogic/providers/default.rb line 48) had
an error: Chef::Exceptions::FileNotFound: Cookbook ‘medya-demo-machines’
(0.0.1) does not contain a file at any of these locations:

templates/redhat-7.0/silent.xml.erb

templates/redhat/silent.xml.erb

templates/default/silent.xml.erb

templates/silent.xml.erb