eventcommand.pp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # == Defined type: icinga2::object::eventcommand
  2. #
  3. # This is a defined type for Icinga 2 apply objects that create event 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-eventcommand
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::eventcommand (
  12. $object_eventcommandname = $name,
  13. $template_to_import = 'plugin-event-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/eventcommands',
  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_eventcommandname)
  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_eventcommand.conf.erb'),
  49. notify => Service['icinga2'],
  50. }
  51. }