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),
}
}
|