Guest User

Untitled

a guest
May 18th, 2015
204
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. default.rb:
  2.  
  3. #
  4. # Cookbook Name:: sm-nagios
  5. # Recipe:: default
  6. #
  7. # Copyright 2015, SecondMarket Labs, LLC
  8. #
  9. # All rights reserved - Do Not Redistribute
  10. #
  11.  
  12. include_recipe "nagios"
  13. include_recipe "sm-nagios::_load_default_config"
  14.  
  15. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  16.  
  17. _load_default_config.rb
  18. nagios_users = NagiosUsers.new(node)
  19. nagios_users.users.each do |item|
  20. o = Nagios::Contact.create(item['id'])
  21. o.import(item.to_hash)
  22. o.import(item['nagios'].to_hash) unless item['nagios'].nil?
  23. o.use = 'default-contact'
  24. end
  25.  
  26. email_only_members = nagios_users.return_user_contacts
  27. email_only_members -= ['pagerduty']
  28.  
  29. nagios_contactgroup 'admins' do
  30. options 'alias' => 'Nagios Administrators',
  31. 'members' => email_only_members
  32. end
  33.  
  34. nagios_contactgroup 'admins-sms' do
  35. options 'alias' => 'Sysadmin SMS',
  36. 'members' => nagios_users.return_user_contacts
  37. end
  38.  
  39. nagios_contactgroups = Nagios.instance.contactgroups
  40.  
  41. begin
  42. t = resources(:template => "#{node['nagios']['config_dir']}/contacts.cfg")
  43. t.source "contacts.cfg.erb"
  44. t.cookbook "sm-nagios"
  45. t.variables(:nagios_contactgroups => Nagios.instance.contactgroups)
  46. #rescue Chef::Exceptions::ResourceNotFound
  47. # Chef::Log.warn "could not find template #{node['nagios']['config_dir']/contacts.cfg to modify"
  48. end
RAW Paste Data