Defined Type: icingaweb2::config::navigation

Defined in:
manifests/config/navigation.pp

Summary

Navigate defines a menu entry, host- or service action.

Overview

Parameters:

  • item_name (String) (defaults to: $title)

    Name of the menu entry, host- or service action.

  • owner (String)

    Owner of the navigation item.

  • type (Enum[ 'menu-item', 'host-action', 'service-action' ]) (defaults to: 'menu-item')

    Type of the navigation item.

  • shared (Boolean) (defaults to: false)

    Creates a shared navigation item.

  • users (Optional[Array[String]]) (defaults to: undef)

    List of users who have access to the element. Only valid if shared.

  • groups (Optional[Array[String]]) (defaults to: undef)

    List of user groups that have access to the element. Only valid if shared.

  • parent (Optional[String]) (defaults to: undef)

    The name of the a parent item. Only valid for menu entries. Important: ‘shared` has to set if the parent entry is also `shared`.

  • target (Enum['_blank', '_main']) (defaults to: '_main')

    The target to view the content.

  • url (String)

    Url to the content of the navigation item.

  • icon (Optional[String]) (defaults to: undef)

    Location of an icon for the navigation item.

  • filter (Optional[String]) (defaults to: undef)

    Filter to restrict the result of the content. Only valid for actions.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'manifests/config/navigation.pp', line 38

define icingaweb2::config::navigation (
  String                  $owner,
  String                  $url,
  String                  $item_name    = $title,
  Enum[
    'menu-item',
    'host-action',
    'service-action'
  ]                       $type         = 'menu-item',
  Boolean                 $shared       = false,
  Optional[Array[String]] $users        = undef,
  Optional[Array[String]] $groups       = undef,
  Enum['_blank', '_main'] $target       = '_main',
  Optional[String]        $parent       = undef,
  Optional[String]        $icon         = undef,
  Optional[String]        $filter       = undef,
) {
  require icingaweb2::globals

  $conf_dir   = $icingaweb2::globals::conf_dir
  $conf_user  = $icingaweb2::conf_user
  $conf_group = $icingaweb2::conf_group

  $ini_file = $type ? {
    'host-action'    => 'host-actions.ini',
    'service-action' => 'service-actions.ini',
    default          => 'menu.ini',
  }

  $settings = {
    'type'   => $type,
    'target' => $target,
    'url'    => $url,
    'users'  => if $users and $shared and (!$parent or $type != 'menu-item') { join($users, ', ') } else { undef },
    'groups' => if $groups and $shared and (!$parent or $type != 'menu-item') { join($groups, ', ') } else { undef },
    'parent' => if $type == 'menu-item' { $parent } else { undef },
    'icon'   => $icon,
    'filter' => unless $type == 'menu-item' { $filter } else { undef },
    'owner'  => if $shared { $owner } else { undef },
  }

  if $shared {
    $file_target = "${conf_dir}/navigation/${ini_file}"
  } else {
    $file_target = "${conf_dir}/preferences/${owner}/${ini_file}"
    ensure_resource('file', "${conf_dir}/preferences/${owner}", {
        ensure => directory,
        owner  => $conf_user,
        group  => $conf_group,
        mode   => '2770',
    })
  }

  icingaweb2::inisection { "navigation-${item_name}":
    section_name => $item_name,
    target       => $file_target,
    settings     => delete_undef_values($settings),
  }
}