bbg-cookbooks / monit-ng

chef cookbook for installing/configuring monit from package or source, with resource provider for managing monit checks
https://github.com/bbg-cookbooks/monit
Apache License 2.0
12 stars 35 forks source link

Undefined method or attribute `only_on' on `node' #36

Closed joshbmarshall closed 9 years ago

joshbmarshall commented 9 years ago

Using Chef Client, version 11.18.0

I get the error

Chef::Mixin::Template::TemplateError (Undefined method or attribute only_on' onnode') on line #39:

37: <% @alert.each do |alert| %> 38: set alert <%= alert.name %> 39: <% if ! alert.only_on.nil? -%> 40: only on { <%= alert.only_on.join(', ') %>} 41: <% elsif ! alert.subscriptions.nil? -%>

Seems to be from the recent changes (today)

nathwill commented 9 years ago

thanks for the report @joshbmarshall! since i wasn't hitting this issue testing against chef 12, i'm guessing this is tied to a change in the ruby version bundled with chef.

breaking compat with chef 11 is obviously not what we want, so i'm going to update the test suite platform list to test against chef 11 and chef 12, as shewn here: https://gist.github.com/fnichol/77c9ba7c64d9b6efa936, and then get to work on a fix.

nathwill commented 9 years ago

hey Josh, I don't seem to be able to replicate under Chef 11 with the existing test suites we've got. can you provide example recipe code that i can use to replicate the problem?

thanks!

joshbmarshall commented 9 years ago

This is what I'm using, on Centos 6.6

node.default['monit']['config']['log_file'] = 'syslog facility log_daemon'
node.default['monit']['config']['mail_from'] = 'alerts@XXXX.co'
node.default['monit']['config']['mail_servers'] = [
  {
    "hostname" => "127.0.0.1",
    "port" => 25,
    "timeout" => "30 seconds",
  }
]
node.default['monit']['config']['subscribers'] = [
    {
      'name'          => 'alerts@XXXX.co',
      'subscriptions' => %w( connection content data exec fsflags gid icmp instance invalid nonexist permission pid ppid resource size timeout timestamp uid ),
    },
    {
      'name'          => 'josh@XXXX.co',
      'subscriptions' => %w( connection content data exec fsflags gid icmp instance invalid nonexist permission pid ppid resource size timeout timestamp uid ),
    },
    {
      'name'          => 'tom@XXXX.co',
      'subscriptions' => %w( connection content data exec fsflags gid icmp invalid nonexist permission pid ppid resource size timeout timestamp uid ),
    },
  ]

  # Monit
  include_recipe 'monit-ng'
  include_recipe 'monit-ng::source'
  include_recipe 'monit-ng::config'
nathwill commented 9 years ago

excellent, thanks! looks like this broke in https://github.com/bbg-cookbooks/monit-ng/commit/4c51556dca12dde1aee32afcf271f4b0857cd8c2, which added better event filtering with only_on and but_not_on, but the backwards compatibility didn't quite work as intended.

i updated the test cookbook to exercise all three forms of the supported alert/subscriptions hashes and fixed up the template, so this should be working now in 1.8.1, which i just pushed to the supermarket.

thanks again, and please let us know if you run into any further problems!