I'm new to chef, and I'm trying to setup a wrapper cookbook to manage logstash. The cookbook I am wrapping uses LWRP.
How do you manage a config file using a LWRP?
Here is the wrapper cookbook that I have so far
recipes/default.rb
include_recipe 'apt::default'
include_recipe 'java::default'
include_recipe 'logstash::server'
attributes/default.rb
default['logstash']['instance_default']['elasticsearch_cluster'] = 'example-elasticsearch'
default['logstash']['instance_default']['elasticsearch_ip'] = 'elasticsearch01.example.com'
default['logstash']['instance_default']['elasticsearch_port'] = '9200'
default['logstash']['instance_default']['elasticsearch_embedded'] = false
Berksfile
source "https://supermarket.chef.io"
metadata
cookbook 'logstash', git: 'https://github.com/lusis/chef-logstash.git'
According to the documentation, there is an example of using a LWRP in the .kitchen.yml, but I'm not sure how to use it.
Where do I put the LWRP definitions?
What does a LWRP look like inside a wrapper cookbook?
Update
Here is what I have tried:
In recipe/default.rb
I've added the following
include_recipe 'apt::default'
include_recipe 'java::default'
include_recipe 'logstash::server'
logstash_config 'config/foobar_output_elasticsearch.conf.erb' do
action [:create]
notifies :restart, "logstash_service[#{name}]"
end
Then inside templates/default/config/foobar_output_elasticsearch.conf.erb
I have the following
foobar
Yet when I run a kitchen converge, the file is not created
Update2
According to cheeseplus in the irc channel, you should be able to use a LWRP like so:
default['logstash']['instance_default']['config_templates_cookbook'] = 'config/foobar_output_elasticsearch.conf.erb'
https://github.com/lusis/chef-logstash/issues/367
Unfortunately it doesn't work.
Update3
I've also tried setting attributes in my default.rb like so:
default['logstash']['instance_default']['config_templates_cookbook'] = 'My-Wrapper-Cookobook'
default['logstash']['instance_default']['config_templates']['foobar'] = 'config/foobar_output_elasticsearch.conf.erb'
Update4
I've also tried setting the parameters in the resource directly with no luck.
logstash_config 'foobar' do
templates_cookbook 'MY-Wrapper-Cookbook'
templates 'config/foobar_output_elasticsearch.conf.erb'
action [:create]
notifies :restart, "logstash_service[#{name}]"
end
Update5
Looking at this example, I've also tried the following syntax.
default['logstash']['instance_default']['config_templates'] = {
'input_redis' => 'config/input_redis.conf.erb',
'filter_syslog' => 'config/filter_syslog.conf.erb',
'output_elasticsearch' => 'config/output_elasticsearch.conf.erb',
'foobar' => 'config/foobar_output_elasticsearch.conf.erb'
}