Coder Social home page Coder Social logo

Comments (3)

westbywest avatar westbywest commented on August 16, 2024

Perhaps related: my nagios cookbook execution fails on the ip_to_monitor() method. Specifically, it complains about monitored_host['cloud']['public_ipv4'].include?('.') being evaluated on nodes that where monitored_host['cloud'] exists but monitored_host['cloud']['public_ipv4'] isn't defined. This is probably because I have a couple nodes not on any cloud provider (bare metal, vagrant, etc).

Recipe: nagios::default
  * directory[/etc/nagios3] action create (up to date)
  * template[/etc/nagios3/htpasswd.users] action create (up to date)
  * template[/etc/nagios3/nagios.cfg] action create (up to date)
  * directory[/etc/nagios3/dist] action create (up to date)
  * directory[/var/lib/nagios3] action create (up to date)
  * directory[/var/lib/nagios3/rw] action create (up to date)
  * execute[archive-default-nagios-object-definitions] action run (skipped due to not_if)
  * directory[/etc/nagios3/certificates] action create (up to date)
  * bash[Create SSL Certificates] action run (skipped due to not_if)
  * template[/etc/nagios3/nagios.cfg] action create (up to date)
  * template[/etc/nagios3/cgi.cfg] action create (up to date)
  * template[/etc/nagios3/conf.d/timeperiods.cfg] action create (up to date)
  * template[/etc/nagios3/conf.d/templates.cfg] action create (up to date)
  * template[/etc/nagios3/conf.d/commands.cfg] action create (up to date)
  * template[/etc/nagios3/conf.d/services.cfg] action create (up to date)
  * template[/etc/nagios3/conf.d/servicegroups.cfg] action create (up to date)
  * template[/etc/nagios3/conf.d/contacts.cfg] action create (up to date)
  * template[/etc/nagios3/conf.d/hostgroups.cfg] action create (up to date)
  * template[/etc/nagios3/conf.d/hosts.cfg] action create

    ================================================================================
    Error executing action `create` on resource 'template[/etc/nagios3/conf.d/hosts.cfg]'
    ================================================================================

    Chef::Mixin::Template::TemplateError
    ------------------------------------
    undefined method `include?' for nil:NilClass

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/nagios/definitions/nagios_conf.rb

     29:   template "#{conf_dir}/#{params[:name]}.cfg" do
     30:     owner node['nagios']['user']
     31:     group node['nagios']['group']
     32:     source params[:source]
     33:     mode 00644
     34:     variables params[:variables]
     35:     notifies :reload, 'service[nagios]'
     36:     backup 0
     37:   end
     38: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/nagios/definitions/nagios_conf.rb:29:in `block in from_file'

    template("/etc/nagios3/conf.d/hosts.cfg") do
      params {:variables=>{:nodes=>[...], :unmanaged_hosts=>[], :hostgroups=>[...}, :config_subdir=>true, :source=>"hosts.cfg.erb", :name=>"hosts"}
      provider Chef::Provider::Template
      action "create"
      retries 0
      retry_delay 2
      guard_interpreter :default
      path "/etc/nagios3/conf.d/hosts.cfg"
      backup 0
      atomic_update true
      source "hosts.cfg.erb"
      variables {:nodes=>[...], :unmanaged_hosts=>[], :hostgroups=>[...]}
      cookbook_name "nagios"
      recipe_name "default"
      owner "nagios"
      group "nagios"
      mode 420
    end

    Template Context:
    -----------------
    on line #17
     15: define host {
     16:   use server
     17:   address <%= ip_to_monitor(n) %>
     18:   <% host_name = (n[node['nagios']['host_name_attribute']] ? n[node['nagios']['host_name_attribute']] : n.name) -%>
     19:   host_name <%= node['nagios']['server']['normalize_hostname'] ? host_name.downcase : host_name %>


Running handlers:
[2014-08-26T16:01:36+00:00] ERROR: Running exception handlers
[2014-08-26T16:01:36+00:00] ERROR: Creating JSON exception report
  - Chef::Handler::JsonFile
Running handlers complete
[2014-08-26T16:01:37+00:00] ERROR: Exception handlers complete
[2014-08-26T16:01:37+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 2 resources updated in 24.742224287 seconds
[2014-08-26T16:01:37+00:00] ERROR: 

Chef::Mixin::Template::TemplateError (undefined method `include?' for nil:NilClass) on line #17:

 15: define host {
 16:   use server
 17:   address <%= ip_to_monitor(n) %>
 18:   <% host_name = (n[node['nagios']['host_name_attribute']] ? n[node['nagios']['host_name_attribute']] : n.name) -%>
 19:   host_name <%= node['nagios']['server']['normalize_hostname'] ? host_name.downcase : host_name %>

  /var/chef/cache/cookbooks/nagios/libraries/default.rb:56:in `ip_to_monitor'
  (erubis):17:in `block (2 levels) in evaluate'
  (erubis):13:in `each'
  (erubis):13:in `block in evaluate'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `instance_eval'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `evaluate'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/mixin/template.rb:126:in `_render_template'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/mixin/template.rb:112:in `render_template'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider/template/content.rb:43:in `file_for_provider'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/file_content_management/content_base.rb:40:in `tempfile'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider/file.rb:411:in `tempfile'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider/file.rb:350:in `do_contents_changes'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider/file.rb:121:in `action_create'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider.rb:121:in `run_action'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource.rb:648:in `run_action'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:49:in `run_action'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:81:in `block (2 levels) in converge'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:81:in `each'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:81:in `block in converge'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection.rb:96:in `execute_each_resource'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:80:in `converge'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:345:in `converge'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:431:in `do_run'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:213:in `block in run'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:207:in `fork'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:207:in `run'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application.rb:236:in `run_chef_client'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application/client.rb:338:in `block in run_application'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application/client.rb:327:in `loop'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application/client.rb:327:in `run_application'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application.rb:55:in `run'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/bin/chef-client:26:in `<top (required)>'
  /usr/bin/chef-client:23:in `load'
  /usr/bin/chef-client:23:in `<main>'


[2014-08-26T16:01:37+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
root@ip-10-18-135-41:/etc/nagios3/conf.d# cat hosts.cfg 

from nagios.

sbotman avatar sbotman commented on August 16, 2024

Also this issue is open way to long, sorry about that. Problem should be solved with cookbook version 7.x or higher. Please re-test this with the new cookbook and I will close the ticket for now, but please feel free to re-open it when the problem is still active and I will try to find a solid solution for you.

from nagios.

lock avatar lock commented on August 16, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from nagios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.