notificationcommand.pp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # == Defined type: icinga2::object::notificationcommand
  2. #
  3. # This is a defined type for Icinga 2 apply objects that create notification commands
  4. # See the following Icinga 2 doc page for more info:
  5. # http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-notificationcommand
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::notificationcommand (
  12. $object_notificationcommandname = $name,
  13. $template_to_import = 'plugin-notification-command',
  14. /* $methods = undef, */ /* Need to get more details about this attribute */
  15. $command = undef,
  16. $cmd_path = 'PluginDir',
  17. $arguments = {},
  18. $env = {},
  19. $vars = {},
  20. $timeout = undef,
  21. $target_dir = '/etc/icinga2/objects/notificationcommands',
  22. $target_file_name = "${name}.conf",
  23. $target_file_owner = 'root',
  24. $target_file_group = 'root',
  25. $target_file_mode = '0644'
  26. ) {
  27. #Do some validation of the class' parameters:
  28. validate_string($object_notificationcommandname)
  29. validate_string($template_to_import)
  30. validate_array($command)
  31. validate_string($cmd_path)
  32. validate_hash($arguments)
  33. validate_hash($env)
  34. validate_hash($vars)
  35. if $timeout {
  36. validate_re($timeout, '^\d+$')
  37. }
  38. validate_string($target_dir)
  39. validate_string($target_file_name)
  40. validate_string($target_file_owner)
  41. validate_string($target_file_group)
  42. validate_re($target_file_mode, '^\d{4}$')
  43. file {"${target_dir}/${target_file_name}":
  44. ensure => file,
  45. owner => $target_file_owner,
  46. group => $target_file_group,
  47. mode => $target_file_mode,
  48. content => template('icinga2/object_notificationcommand.conf.erb'),
  49. notify => Service['icinga2'],
  50. }
  51. }