|
12 | 12 | # 'puppet' copies the key, cert and CAcert from the Puppet ssl directory to the pki directory |
13 | 13 | # /etc/icinga2/pki on Linux and C:/ProgramData/icinga2/etc/icinga2/pki on Windows. |
14 | 14 | # 'none' does nothing and you either have to manage the files yourself as file resources |
15 | | -# or use the ssl_key, ssl_cert, ssl_ca parameters. Defaults to puppet. |
| 15 | +# or use the ssl_key, ssl_cert, ssl_cacert parameters. Defaults to puppet. |
16 | 16 | # |
17 | 17 | # [*ssl_key_path*] |
18 | 18 | # Location of the private key. Default depends on platform: |
|
26 | 26 | # C:/ProgramData/icinga2/etc/icinga2/pki/NodeName.crt on Windows |
27 | 27 | # The Value of NodeName comes from the corresponding constant. |
28 | 28 | # |
29 | | -# [*ssl_ca_path*] |
| 29 | +# [*ssl_cacert_path*] |
30 | 30 | # Location of the CA certificate. Default is: |
31 | 31 | # /etc/icinga2/pki/ca.crt on Linux |
32 | 32 | # C:/ProgramData/icinga2/etc/icinga2/pki/ca.crt on Windows |
33 | 33 | # |
34 | | -# [*ssl_key*] NOT IMPLEMENTED |
35 | | -# The private key in a base64 encoded string to store in pki directory, file is named to the constants 'NodeName' |
36 | | -# with the suffix '.key'. For use 'pki' must set to 'none'. Defaults to undef. |
| 34 | +# [*ssl_key*] |
| 35 | +# The private key in a base64 encoded string to store in pki directory, file is stored to |
| 36 | +# path spicified in ssl_key_path. To affect this parameter pki has to set to 'none'. |
37 | 37 | # |
38 | | -# [*ssl_cert*] NOT IMPLEMENTED |
39 | | -# The certificate in a base64 encoded string to store in pki directory, file is named to the constants 'NodeName' |
40 | | -# with the suffix '.crt'. For use 'pki' must set to 'none'. Defaults to undef. |
| 38 | +# [*ssl_cert*] |
| 39 | +# The certificate in a base64 encoded string to store in pki directory, file is stored to |
| 40 | +# path spicified in ssl_cert_path. To affect this parameter pki has to set to 'none'. |
41 | 41 | # |
42 | | -# [*ssl_ca*] NOT IMPLEMENTED |
43 | | -# The CA root certificate in a base64 encoded string to store in pki directory, file is named to 'ca.crt'. |
44 | | -# For use 'pki' must set to 'none'. Defaults to undef. |
| 42 | +# [*ssl_cacert*] |
| 43 | +# The CA root certificate in a base64 encoded string to store in pki directory, file is stored |
| 44 | +# to path spicified in ssl_cacert_path. To affect this parameter pki has to set to 'none'. |
45 | 45 | # |
46 | 46 | # [*accept_config*] |
47 | 47 | # Accept zone configuration. Defaults to false. |
|
71 | 71 | # [*_ssl_cert_path*] |
72 | 72 | # Validated path to certificate file. |
73 | 73 | # |
74 | | -# [*_ssl_ca_path*] |
| 74 | +# [*_ssl_casert_path*] |
75 | 75 | # Validated path to root CA certificate file. |
76 | 76 | # |
77 | 77 | # === Examples |
|
105 | 105 | # |
106 | 106 | # class { 'icinga2::feature::api': |
107 | 107 | # pki => 'none', |
108 | | -# ssl_ca_cert => '-----BEGIN CERTIFICATE----- ...', |
| 108 | +# ssl_cacert => '-----BEGIN CERTIFICATE----- ...', |
109 | 109 | # ssl_key => '-----BEGIN RSA PRIVATE KEY----- ...', |
110 | 110 | # ssl_cert => '-----BEGIN CERTIFICATE----- ...', |
111 | 111 | # } |
|
119 | 119 | $pki = 'puppet', |
120 | 120 | $ssl_key_path = undef, |
121 | 121 | $ssl_cert_path = undef, |
122 | | - $ssl_ca_path = undef, |
| 122 | + $ssl_cacert_path = undef, |
123 | 123 | $accept_config = false, |
124 | 124 | $accept_commands = false, |
125 | 125 | $ticket_salt = 'TicketSalt', |
126 | 126 | $endpoints = { 'NodeName' => {} }, |
127 | 127 | $zones = { 'ZoneName' => { endpoints => [ 'NodeName' ] } }, |
| 128 | + $ssl_key = undef, |
| 129 | + $ssl_cert = undef, |
| 130 | + $ssl_cacert = undef, |
128 | 131 | ) { |
129 | 132 |
|
130 | 133 | include ::icinga2::params |
|
162 | 165 | $_ssl_cert_path = $ssl_cert_path } |
163 | 166 | else { |
164 | 167 | $_ssl_cert_path = "${pki_dir}/${node_name}.crt" } |
165 | | - if $ssl_ca_path { |
166 | | - validate_absolute_path($ssl_ca_path) |
167 | | - $_ssl_ca_path = $ssl_ca_path } |
| 168 | + if $ssl_cacert_path { |
| 169 | + validate_absolute_path($ssl_cacert_path) |
| 170 | + $_ssl_cacert_path = $ssl_cacert_path } |
168 | 171 | else { |
169 | | - $_ssl_ca_path = "${pki_dir}/ca.crt" } |
| 172 | + $_ssl_cacert_path = "${pki_dir}/ca.crt" } |
170 | 173 |
|
171 | 174 | # handle the certificate's stuff |
172 | | - if $pki == 'puppet' { |
173 | | - file { $_ssl_key_path: |
174 | | - ensure => file, |
175 | | - mode => $::kernel ? { |
176 | | - 'windows' => undef, |
177 | | - default => '0600', |
178 | | - }, |
179 | | - source => $::settings::hostprivkey, |
180 | | - tag => 'icinga2::config::file', |
181 | | - } |
182 | | - |
183 | | - file { $_ssl_cert_path: |
184 | | - ensure => file, |
185 | | - source => $::settings::hostcert, |
186 | | - tag => 'icinga2::config::file', |
187 | | - } |
188 | | - |
189 | | - file { $_ssl_ca_path: |
190 | | - ensure => file, |
191 | | - source => $::settings::localcacert, |
192 | | - tag => 'icinga2::config::file', |
193 | | - } |
194 | | - } |
| 175 | + case $pki { |
| 176 | + 'puppet': { |
| 177 | + file { $_ssl_key_path: |
| 178 | + ensure => file, |
| 179 | + mode => $::kernel ? { |
| 180 | + 'windows' => undef, |
| 181 | + default => '0600', |
| 182 | + }, |
| 183 | + source => $::settings::hostprivkey, |
| 184 | + tag => 'icinga2::config::file', |
| 185 | + } |
| 186 | + |
| 187 | + file { $_ssl_cert_path: |
| 188 | + ensure => file, |
| 189 | + source => $::settings::hostcert, |
| 190 | + tag => 'icinga2::config::file', |
| 191 | + } |
| 192 | + |
| 193 | + file { $_ssl_cacert_path: |
| 194 | + ensure => file, |
| 195 | + source => $::settings::localcacert, |
| 196 | + tag => 'icinga2::config::file', |
| 197 | + } |
| 198 | + } # puppet |
| 199 | + |
| 200 | + 'none': { |
| 201 | + if $ssl_key { |
| 202 | + file { $_ssl_key_path: |
| 203 | + ensure => file, |
| 204 | + mode => $::kernel ? { |
| 205 | + 'windows' => undef, |
| 206 | + default => '0600', |
| 207 | + }, |
| 208 | + content => $::osfamily ? { |
| 209 | + 'windows' => regsubst($ssl_key, '\n', "\r\n", 'EMG'), |
| 210 | + default => $ssl_key, |
| 211 | + }, |
| 212 | + tag => 'icinga2::config::file', |
| 213 | + } |
| 214 | + } |
| 215 | + |
| 216 | + if $ssl_cert { |
| 217 | + file { $_ssl_cert_path: |
| 218 | + ensure => file, |
| 219 | + content => $::osfamily ? { |
| 220 | + 'windows' => regsubst($ssl_cert, '\n', "\r\n", 'EMG'), |
| 221 | + default => $ssl_cert, |
| 222 | + }, |
| 223 | + tag => 'icinga2::config::file', |
| 224 | + } |
| 225 | + } |
| 226 | + |
| 227 | + if $ssl_cacert { |
| 228 | + file { $_ssl_cacert_path: |
| 229 | + ensure => file, |
| 230 | + content => $::osfamily ? { |
| 231 | + 'windows' => regsubst($ssl_cacert, '\n', "\r\n", 'EMG'), |
| 232 | + default => $ssl_cacert, |
| 233 | + }, |
| 234 | + tag => 'icinga2::config::file', |
| 235 | + } |
| 236 | + } |
| 237 | + } # none |
| 238 | + } # pki |
195 | 239 |
|
196 | 240 | # compose attributes |
197 | 241 | $attrs = { |
198 | 242 | cert_path => $_ssl_cert_path, |
199 | 243 | key_path => $_ssl_key_path, |
200 | | - ca_path => $_ssl_ca_path, |
| 244 | + ca_path => $_ssl_cacert_path, |
201 | 245 | accept_commands => $accept_commands, |
202 | 246 | accept_config => $accept_config, |
203 | 247 | ticket_salt => $ticket_salt, |
|
0 commit comments