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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'manifests/feature/gelf.pp', line 46
class icinga2::feature::gelf (
Enum['absent', 'present'] $ensure = present,
Optional[Stdlib::Host] $host = undef,
Optional[Stdlib::Port] $port = undef,
Optional[String[1]] $source = undef,
Boolean $enable_ssl = false,
Optional[Stdlib::Absolutepath] $ssl_key_path = undef,
Optional[Stdlib::Absolutepath] $ssl_cert_path = undef,
Optional[Stdlib::Absolutepath] $ssl_cacert_path = undef,
Optional[Icinga::Secret] $ssl_key = undef,
Optional[String[1]] $ssl_cert = undef,
Optional[String[1]] $ssl_cacert = undef,
Optional[Boolean] $ssl_noverify = undef,
Optional[Boolean] $enable_send_perfdata = undef,
Optional[Boolean] $enable_ha = undef,
) {
if ! defined(Class['icinga2']) {
fail('You must include the icinga2 base class before using any icinga2 feature class!')
}
$owner = $icinga2::globals::user
$group = $icinga2::globals::group
$conf_dir = $icinga2::globals::conf_dir
$ssl_dir = $icinga2::globals::cert_dir
$_notify = $ensure ? {
'present' => Class['icinga2::service'],
default => undef,
}
if $enable_ssl {
$cert = icinga::cert::files(
'GelfWriter_gelf',
$ssl_dir,
$ssl_key_path,
$ssl_cert_path,
$ssl_cacert_path,
$ssl_key,
$ssl_cert,
$ssl_cacert,
)
$attrs_ssl = {
'enable_tls' => true,
'insecure_noverify' => $ssl_noverify,
'ca_path' => $cert['cacert_file'],
'cert_path' => $cert['cert_file'],
'key_path' => $cert['key_file'],
}
# Workaround, icinga::cert doesn't accept undef values for owner and group!
if $facts['os']['family'] != 'windows' {
icinga::cert { 'GelfWriter_gelf':
args => $cert,
owner => $owner,
group => $group,
notify => $_notify,
}
} else {
icinga::cert { 'GelfWriter_gelf':
args => $cert,
owner => 'foo',
group => 'bar',
notify => $_notify,
}
}
} else {
$attrs_ssl = {
'enable_tls' => undef,
'insecure_noverify' => undef,
'ca_path' => undef,
'cert_path' => undef,
'key_path' => undef,
}
$cert = {}
}
# compose attributes
$attrs = {
'host' => $host,
'port' => $port,
'source' => $source,
'enable_send_perfdata' => $enable_send_perfdata,
'enable_ha' => $enable_ha,
}
# create object
icinga2::object { 'icinga2::object::GelfWriter::gelf':
object_name => 'gelf',
object_type => 'GelfWriter',
attrs => delete_undef_values($attrs + $attrs_ssl),
attrs_list => concat(keys($attrs), keys($attrs_ssl)),
target => "${conf_dir}/features-available/gelf.conf",
order => 10,
notify => $_notify,
}
# manage feature
icinga2::feature { 'gelf':
ensure => $ensure,
}
}
|