hectcastro/chef-collectd — pull request #13 by hectcastro (2013-06-06 20:40:07+00:00)
Title: Write_graphite template is missing Host and Port directives

Not sure why Chef isn't adding the Host and Port fields. I have two roles (base and monitoring) set up with client and server-specific attributes. This is a snippet from the monitoring role.

```ruby
'collectd' => {
'graphite_ipaddress' => 'localhost',
'plugins' => {
'write_graphite' => {
'config' => {
'Prefix' => 'collectd.',
'StoreRates' => true,
'AlwaysAppendDS' => false,
'EscapeCharacter' => '_'
}
```

Which creates the following on my VM

```ruby
#
# This file is generated by Chef
# Do not edit, changes will be overwritten
#
LoadPlugin "write_graphite"

Prefix "collectd."
StoreRates true
AlwaysAppendDS false
EscapeCharacter "_"

```

Looking at the logic in 'attribute_driven', it would appear that Host and Port would be inserted along with the attributes I specified in my role, but that's obviously not the case. The logic appears fine, but maybe I'm missing something here...

```ruby
if node.default["collectd"]["plugins"].key?("write_graphite") # This exists so continue
write_graphite = node.default["collectd"]["plugins"]["write_graphite"] # Grab the attributes that were set by the Chef Roles

if node["collectd"]["graphite_ipaddress"].empty? # Not empty .. skip this
[skipped]
else
write_graphite["config"]["Host"] = node["collectd"]["graphite_ipaddress"] # Use the value I set, in this case 'localhost'
end
write_graphite["config"]["Port"] = 2003 # Set Port to 2003
end
```

While, this isn't really a big deal for me since I've alleviated it by adding the two keys to my role, I still think it's something worth checking out/fixing.