Overwriting a template


#1

Hi,

I am working with the redisio cookbook, and I would like to overwrite the init
script template with my own. I see this:

redisio/providers/install.rb:

  template "/etc/init.d/redis#{server_name}" do
source 'redis.init.erb'
cookbook 'redisio'
owner 'root'
group 'root'
mode '0755'
variables({
  :name => server_name,
  :bin_path => bin_path,
  :job_control => current['job_control'],
  :port => current['port'],
  :address => current['address'],
  :user => current['user'],
  :configdir => current['configdir'],
  :piddir => piddir,
  :requirepass => current['requirepass'],
  :shutdown_save => current['shutdown_save'],
  :platform => node['platform'],
  :unixsocket => current['unixsocket'],
  :ulimit => descriptors
  })
only_if { current['job_control'] == 'initd' }
  end

when I use:

rewind :template => “/etc/init.d/redis#{server_name}” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

or

rewind :template => “/etc/init.d/redis6379” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

I keep getting the error:

Chef::Exceptions::ResourceNotFound

Cannot find a resource matching template[/etc/init.d/redis#{server_name}] (did
you define it first?)

Is there a way to overwrite this template with it not being referenced in a
recipe?

Thanks in advance,

Geoff


#2

try

rewind “template [/etc/init.d/redis6379]” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

On Fri, Jun 20, 2014 at 11:04 AM, geoffreyowen@stratalux.com wrote:

Hi,

I am working with the redisio cookbook, and I would like to overwrite the
init
script template with my own. I see this:

redisio/providers/install.rb:

  template "/etc/init.d/redis#{server_name}" do
    source 'redis.init.erb'
    cookbook 'redisio'
    owner 'root'
    group 'root'
    mode '0755'
    variables({
      :name => server_name,
      :bin_path => bin_path,
      :job_control => current['job_control'],
      :port => current['port'],
      :address => current['address'],
      :user => current['user'],
      :configdir => current['configdir'],
      :piddir => piddir,
      :requirepass => current['requirepass'],
      :shutdown_save => current['shutdown_save'],
      :platform => node['platform'],
      :unixsocket => current['unixsocket'],
      :ulimit => descriptors
      })
    only_if { current['job_control'] == 'initd' }
  end

when I use:

rewind :template => “/etc/init.d/redis#{server_name}” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

or

rewind :template => “/etc/init.d/redis6379” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

I keep getting the error:

Chef::Exceptions::ResourceNotFound

Cannot find a resource matching template[/etc/init.d/redis#{server_name}]
(did
you define it first?)

Is there a way to overwrite this template with it not being referenced in a
recipe?

Thanks in advance,

Geoff


#3

huh!
formatting borked

rewind “template[/etc/init.d/redis#{server_name}]” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

On Fri, Jun 20, 2014 at 11:38 AM, Ranjib Dey dey.ranjib@gmail.com wrote:

try

rewind “template [/etc/init.d/redis6379]” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

On Fri, Jun 20, 2014 at 11:04 AM, geoffreyowen@stratalux.com wrote:

Hi,

I am working with the redisio cookbook, and I would like to overwrite the
init
script template with my own. I see this:

redisio/providers/install.rb:

  template "/etc/init.d/redis#{server_name}" do
    source 'redis.init.erb'
    cookbook 'redisio'
    owner 'root'
    group 'root'
    mode '0755'
    variables({
      :name => server_name,
      :bin_path => bin_path,
      :job_control => current['job_control'],
      :port => current['port'],
      :address => current['address'],
      :user => current['user'],
      :configdir => current['configdir'],
      :piddir => piddir,
      :requirepass => current['requirepass'],
      :shutdown_save => current['shutdown_save'],
      :platform => node['platform'],
      :unixsocket => current['unixsocket'],
      :ulimit => descriptors
      })
    only_if { current['job_control'] == 'initd' }
  end

when I use:

rewind :template => “/etc/init.d/redis#{server_name}” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

or

rewind :template => “/etc/init.d/redis6379” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

I keep getting the error:

Chef::Exceptions::ResourceNotFound

Cannot find a resource matching template[/etc/init.d/redis#{server_name}]
(did
you define it first?)

Is there a way to overwrite this template with it not being referenced in
a
recipe?

Thanks in advance,

Geoff


#4

Darn, no luck. Either way it says:

Recipe Compile Error in
/var/chef/cache/cookbooks/role_redisserver/recipes/default.rb

Chef::Exceptions::ResourceNotFound

Cannot find a resource matching template[/etc/init.d/redis6379] (did you
define it first?)

Is it because the file is referenced in a provider? So it hasn’t been
defined yet?

On Fri, Jun 20, 2014 at 1:40 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

huh!
formatting borked

rewind “template[/etc/init.d/redis#{server_name}]” do

source "redis.init.erb"
cookbook_name "role_redisserver"
end

On Fri, Jun 20, 2014 at 11:38 AM, Ranjib Dey dey.ranjib@gmail.com wrote:

try

rewind “template [/etc/init.d/redis6379]” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

On Fri, Jun 20, 2014 at 11:04 AM, geoffreyowen@stratalux.com wrote:

Hi,

I am working with the redisio cookbook, and I would like to overwrite
the init
script template with my own. I see this:

redisio/providers/install.rb:

  template "/etc/init.d/redis#{server_name}" do
    source 'redis.init.erb'
    cookbook 'redisio'
    owner 'root'
    group 'root'
    mode '0755'
    variables({
      :name => server_name,
      :bin_path => bin_path,
      :job_control => current['job_control'],
      :port => current['port'],
      :address => current['address'],
      :user => current['user'],
      :configdir => current['configdir'],
      :piddir => piddir,
      :requirepass => current['requirepass'],
      :shutdown_save => current['shutdown_save'],
      :platform => node['platform'],
      :unixsocket => current['unixsocket'],
      :ulimit => descriptors
      })
    only_if { current['job_control'] == 'initd' }
  end

when I use:

rewind :template => “/etc/init.d/redis#{server_name}” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

or

rewind :template => “/etc/init.d/redis6379” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

I keep getting the error:

Chef::Exceptions::ResourceNotFound

Cannot find a resource matching
template[/etc/init.d/redis#{server_name}] (did
you define it first?)

Is there a way to overwrite this template with it not being referenced
in a
recipe?

Thanks in advance,

Geoff


#5

I did a little digging over the weekend, and it looks like it is loading my
default recipe first, so the template has not been defined for redisio yet.
I have the order set so it should be running the recipe first, but the
redisio install.rb doesn’t have the “template” in it. Rather it is
contained in the “providers/install.rb”. Is there anyway to override this
in the provider?

Thanks,

Geoff

On Fri, Jun 20, 2014 at 2:08 PM, Geoffrey Owen geoffreyowen@stratalux.com
wrote:

Darn, no luck. Either way it says:

================================================================================
Recipe Compile Error in
/var/chef/cache/cookbooks/role_redisserver/recipes/default.rb

================================================================================

Chef::Exceptions::ResourceNotFound

Cannot find a resource matching template[/etc/init.d/redis6379] (did you
define it first?)

Is it because the file is referenced in a provider? So it hasn’t been
defined yet?

On Fri, Jun 20, 2014 at 1:40 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

huh!
formatting borked

rewind “template[/etc/init.d/redis#{server_name}]” do

source "redis.init.erb"
cookbook_name "role_redisserver"
end

On Fri, Jun 20, 2014 at 11:38 AM, Ranjib Dey dey.ranjib@gmail.com
wrote:

try

rewind “template [/etc/init.d/redis6379]” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

On Fri, Jun 20, 2014 at 11:04 AM, geoffreyowen@stratalux.com wrote:

Hi,

I am working with the redisio cookbook, and I would like to overwrite
the init
script template with my own. I see this:

redisio/providers/install.rb:

  template "/etc/init.d/redis#{server_name}" do
    source 'redis.init.erb'
    cookbook 'redisio'
    owner 'root'
    group 'root'
    mode '0755'
    variables({
      :name => server_name,
      :bin_path => bin_path,
      :job_control => current['job_control'],
      :port => current['port'],
      :address => current['address'],
      :user => current['user'],
      :configdir => current['configdir'],
      :piddir => piddir,
      :requirepass => current['requirepass'],
      :shutdown_save => current['shutdown_save'],
      :platform => node['platform'],
      :unixsocket => current['unixsocket'],
      :ulimit => descriptors
      })
    only_if { current['job_control'] == 'initd' }
  end

when I use:

rewind :template => “/etc/init.d/redis#{server_name}” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

or

rewind :template => “/etc/init.d/redis6379” do
source "redis.init.erb"
cookbook_name "role_redisserver"
end

I keep getting the error:

Chef::Exceptions::ResourceNotFound

Cannot find a resource matching
template[/etc/init.d/redis#{server_name}] (did
you define it first?)

Is there a way to overwrite this template with it not being referenced
in a
recipe?

Thanks in advance,

Geoff