A Chef node considers hash keys as strings, by having symbols and
strings the hash can not merge properly and as a result, adding another
graphite key to the extra_config results in a hash with two
graphite keys.
The result is that there is no way at the moment to add any more values to the graphite
key (see https://github.com/etsy/statsd/blob/master/docs/namespacing.md
for more examples)
To go around this problem the first thing to do is to remove symbols
from the config_hash hash and turn them into strings.
The second thing is to then do a "deep merge" since a regular merge will
only go down one level in the hash. To accomplish this we take advantage
of the Chef Mixins.
config_hash should really be a node attribute to prevent this type of
behavior and let Chef handle the deep merges but for the sake of
backward compatibility it was left as is. However this should be
considered when bumping the cookbook to a major release.
A Chef node considers hash keys as strings, by having symbols and strings the hash can not merge properly and as a result, adding another
graphite
key to theextra_config
results in a hash with twographite
keys. The result is that there is no way at the moment to add any more values to thegraphite
key (see https://github.com/etsy/statsd/blob/master/docs/namespacing.md for more examples)To go around this problem the first thing to do is to remove symbols from the
config_hash
hash and turn them into strings. The second thing is to then do a "deep merge" since a regular merge will only go down one level in the hash. To accomplish this we take advantage of the Chef Mixins.config_hash
should really be a node attribute to prevent this type of behavior and let Chef handle the deep merges but for the sake of backward compatibility it was left as is. However this should be considered when bumping the cookbook to a major release.This allows the user to do things like this:
And the output of the config.js will be