Problems with log stash cookbook and environment attributes


#1

I’m having trouble using the community logstash cookbook with environment parameters.

When it tries to create shipper.conf it fails here:

Chef::Mixin::Template::TemplateError (comparison of String with Chef::Node::ImmutableMash failed) on line #13:

11: }
12: <% else %>
13: <%= LogstashConf.section_to_str(node[‘logstash’][‘agent’][‘inputs’]) %>
14: <% end -%>
15: }

The full stack trace and the environment JSON can be found here: https://gist.github.com/cassianoleal/6116305

I have successfully used this cookbook on another environment when setting [:logstash][:agent][:inputs] via node.override in a recipe. What’s wrong with this approach?

Cheers,

Cassiano Leal
http://cassianoleal.com
http://twitter.com/cassianoleal


#2

On Tuesday, July 30, 2013 at 1:10 PM, Cassiano Leal wrote:

I’m having trouble using the community logstash cookbook with environment parameters.

When it tries to create shipper.conf it fails here:

Chef::Mixin::Template::TemplateError (comparison of String with Chef::Node::ImmutableMash failed) on line #13:

11: }
12: <% else %>
13: <%= LogstashConf.section_to_str(node[‘logstash’][‘agent’][‘inputs’]) %>
14: <% end -%>
15: }

The full stack trace and the environment JSON can be found here: https://gist.github.com/cassianoleal/6116305

I have successfully used this cookbook on another environment when setting [:logstash][:agent][:inputs] via node.override in a recipe. What’s wrong with this approach?

Cheers,

Cassiano Leal
http://cassianoleal.com
http://twitter.com/cassianoleal

If you haven’t figured this out yet, it looks like you’re ending up in a situation where the log stash cookbook has an array like:

[ “string”, “another string”, {:attribute_data => “some data”}]

… And then calls #sort on that array. This implies that node['logstash']['agent']['inputs'] is expected to be a string but is a hash instead. Or something like that.


Daniel DeLeo


#3

On August 8, 2013 at 16:13:52, Daniel DeLeo (dan@kallistec.com) wrote:

On Tuesday, July 30, 2013 at 1:10 PM, Cassiano Leal wrote:

I’m having trouble using the community logstash cookbook with environment parameters.

When it tries to create shipper.conf it fails here:

Chef::Mixin::Template::TemplateError (comparison of String with Chef::Node::ImmutableMash failed) on line #13:

11: }
12: <% else %>
13: <%= LogstashConf.section_to_str(node[‘logstash’][‘agent’][‘inputs’]) %>
14: <% end -%>
15: }

The full stack trace and the environment JSON can be found here: https://gist.github.com/cassianoleal/6116305

I have successfully used this cookbook on another environment when setting [:logstash][:agent][:inputs] via node.override in a recipe. What’s wrong with this approach?

Cheers,

Cassiano Leal
http://cassianoleal.com
http://twitter.com/cassianoleal
If you haven’t figured this out yet, it looks like you’re ending up in a situation where the log stash cookbook has an array like:

[ “string”, “another string”, {:attribute_data => “some data”}]

… And then calls #sort on that array. This implies that node['logstash']['agent']['inputs'] is expected to be a string but is a hash instead. Or something like that.

I haven’t. I took a different path.

What you’re saying makes a lot of sense, though. This:

“override_attributes”: {
“logstash”: {
“agent”: {
“inputs”: {
“file”: {

}
},
confirms that node[:logstash][:agent][:inputs] really is a Hash.

Thanks for the information, I’ll keep that in mind next time I do that! :slight_smile:


Daniel DeLeo


Cassiano Leal
http://cassianoleal.com
http://twitter.com/cassianoleal


#4

On Thursday, August 8, 2013 at 12:48 PM, Cassiano Leal wrote:

On August 8, 2013 at 16:13:52, Daniel DeLeo (dan@kallistec.com (mailto:dan@kallistec.com)) wrote:

On Tuesday, July 30, 2013 at 1:10 PM, Cassiano Leal wrote:

I’m having trouble using the community logstash cookbook with environment parameters.

When it tries to create shipper.conf it fails here:

Chef::Mixin::Template::TemplateError (comparison of String with Chef::Node::ImmutableMash failed) on line #13:

11: }
12: <% else %>
13: <%= LogstashConf.section_to_str(node[‘logstash’][‘agent’][‘inputs’]) %>
14: <% end -%>
15: }

The full stack trace and the environment JSON can be found here: https://gist.github.com/cassianoleal/6116305

I have successfully used this cookbook on another environment when setting [:logstash][:agent][:inputs] via node.override in a recipe. What’s wrong with this approach?

Cheers,

Cassiano Leal
http://cassianoleal.com
http://twitter.com/cassianoleal

If you haven’t figured this out yet, it looks like you’re ending up in a situation where the log stash cookbook has an array like:

[ “string”, “another string”, {:attribute_data => “some data”}]

… And then calls #sort on that array. This implies that node['logstash']['agent']['inputs'] is expected to be a string but is a hash instead. Or something like that.

I haven’t. I took a different path.

What you’re saying makes a lot of sense, though. This:

“override_attributes”: {
“logstash”: {
“agent”: {
“inputs”: {
“file”: {

}
},

confirms that node[:logstash][:agent][:inputs] really is a Hash.
Thanks for the information, I’ll keep that in mind next time I do that! :slight_smile:

Just to be clear, I don’t personally have experience with the log stash cookbook, so I’m not sure what type it expects the input to be, just that somehow it’s trying to sort things of different types, which ruby doesn’t like.


Daniel DeLeo

–Cassiano Leal
http://cassianoleal.com
http://twitter.com/cassianoleal


Daniel DeLeo