puppet-collectd
puppet-collectd copied to clipboard
[Puppet4] Field named type in hash results in errors
Puppet 4.4.1 did not accept an field named "type" in a hash on my machine. The quoting of the field below works but it would be great if the name could be changed so it works without quotes.
collectd::plugin::tail::file {
'spamd-log':
filename => '/var/log/spamd.log',
instance => 'spamassassin',
matches => [
{
regex => 'spamd:\ checking\ message',
dstype => 'CounterInc',
'type' => 'counter',
instance => 'checking',
},
{
regex => 'spamd:\ clean\ message',
dstype => 'CounterInc',
'type' => 'counter',
instance => 'clean',
},
{
regex => 'spamd:\ identified\ message',
dstype => 'CounterInc',
'type' => 'counter',
instance => 'spam',
},
]
}
If type is unquoted it results in
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Found 3 errors. Giving up
Environment was puppet-collectd-4.3.0
Do you have a recommendation for a new parameter name?
It depends on the profile. Type is used in many “matches“ hashes of profiles. In this case I would say “match_type“. In others it could be “file_type“ for example.
On 31 May 2016 20:52:05 CEST, "Joseph (Jy) Yaworski" [email protected] wrote:
Do you have a recommendation for a new parameter name?
You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/voxpupuli/puppet-collectd/issues/504#issuecomment-222784440
https://tickets.puppetlabs.com/browse/PUP-4887
Having to quote the reserved word might be better than changing/breaking the API??
At least it is not working as documented. It would also work if the documentation would list the variable 'type' as being quoted.
On 1 June 2016 10:42:51 CEST, Alex Fisher [email protected] wrote:
https://tickets.puppetlabs.com/browse/PUP-4887
You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/voxpupuli/puppet-collectd/issues/504#issuecomment-222929917
@alexjfisher @gna582 I disagree. We should change it to not be a reserved word. Even if this breaks the existing API for things that use it, an entry in the changelog should suffice. It's more cumbersome for users to remember to quote something.
People getting their collectd::plugin::tail::file resources from hiera are unaffected by type being a keyword. They would be inconvenienced by an API change though. That said, I don't feel that strongly about changing it. @jyaworski - worth getting a consensus on IRC before making any decision? More than just updating the changelog, I think you'd need to add some extra validation here https://github.com/voxpupuli/puppet-collectd/blob/master/manifests/plugin/tail/file.pp#L17 something perhaps like...
if has_key ($matches[0], 'type') {
fail("use NEW_PARAM instead of 'type'")
}