user.pp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # == Defined type: icinga2::object::user
  2. #
  3. # This is a defined type for Icinga 2 user objects.
  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-user
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::user (
  12. $object_username = $name,
  13. $display_name = $name,
  14. $email = undef,
  15. $pager = undef,
  16. $vars = {},
  17. $groups = [],
  18. $enable_notifications = undef,
  19. $period = undef,
  20. $types = [],
  21. $states = [],
  22. $target_dir = '/etc/icinga2/conf.d',
  23. $target_file_name = "${name}.conf",
  24. $target_file_owner = 'root',
  25. $target_file_group = 'root',
  26. $target_file_mode = '644'
  27. ) {
  28. #Do some validation of the class' parameters:
  29. validate_string($object_username)
  30. validate_string($display_name)
  31. validate_string($host_name)
  32. validate_array($groups)
  33. validate_hash($vars)
  34. validate_array($types)
  35. validate_array($states)
  36. validate_string($target_dir)
  37. validate_string($target_file_name)
  38. validate_string($target_file_owner)
  39. validate_string($target_file_group)
  40. validate_string($target_file_mode)
  41. file {"${target_dir}/${target_file_name}":
  42. ensure => file,
  43. owner => $target_file_owner,
  44. group => $target_file_group,
  45. mode => $target_file_mode,
  46. content => template('icinga2/object_user.conf.erb'),
  47. notify => Service['icinga2'],
  48. }
  49. }