2012-09-18 02:06:48 +02:00
class puppetdb: : server: : firewall(
2012-11-13 21:38:38 +01:00
$ port = '' ,
$ http_port = $ puppetdb: : params: : listen_port,
$ open_http_port = $ puppetdb: : params: : open_listen_port,
$ ssl_port = $ puppetdb: : params: : ssl_listen_port,
$ open_ssl_port = $ puppetdb: : params: : open_ssl_listen_port,
2012-09-18 02:06:48 +02:00
$ manage_redhat_firewall = $ puppetdb: : params: : manage_redhat_firewall,
) inherits puppetdb: : params {
# TODO: figure out a way to make this not platform - specific; debian and ubuntu
# have an out - of - the- box firewall configuration that seems trickier to manage.
# TODO: the firewall module should be able to handle this itself
2012-11-13 21:38:38 +01:00
if ( $ puppetdb: : params: : firewall_supported) {
2013-01-17 02:52:11 +01:00
if ( $ manage_redhat_firewall ! = undef) {
2012-11-13 21:38:38 +01:00
notify {'Deprecation notice: `$manage_redhat_firewall` is deprecated in the `puppetdb::service::firewall` class and will be removed in a future version. Use `open_http_port` and `open_ssl_port` instead.':}
2013-01-17 02:52:11 +01:00
if ( $ open_ssl_port ! = undef) {
2012-11-13 21:38:38 +01:00
fail( '`$manage_redhat_firewall` and `$open_ssl_port` cannot both be specified.' )
}
}
2012-09-18 02:06:48 +02:00
2012-09-21 19:17:42 +02:00
exec { 'puppetdb-persist-firewall' :
2012-09-20 23:46:26 +02:00
command = > $ puppetdb: : params: : persist_firewall_command,
refreshonly = > true ,
}
2012-09-18 02:06:48 +02:00
2012-09-20 23:46:26 +02:00
Firewall {
2012-09-21 19:17:42 +02:00
notify = > Exec[ 'puppetdb-persist-firewall' ]
2012-09-20 23:46:26 +02:00
}
2012-11-13 21:38:38 +01:00
if ( $ port) {
notify { 'Deprecation notice: `port` parameter will be removed in future versions of the puppetdb module. Please use ssl_port instead.': }
}
if ( $ port and $ ssl_port) {
fail( '`port` and `ssl_port` cannot both be defined. `port` is deprecated in favor of `ssl_port`' )
}
if ( $ open_http_port) {
firewall { "${http_port} accept - puppetdb" :
port = > $ http_port,
proto = > 'tcp' ,
action = > 'accept' ,
}
2013-01-17 02:52:11 +01:00
}
2013-01-17 18:56:01 +01:00
# This technically defaults to 'true' , but in order to preserve backwards
# compatibility with the deprecated 'manage_redhat_firewall' parameter, we
# had to specify 'undef' as the default so that we could tell whether or
# not the user explicitly specified a value. Here's where we' re resolving
# that and setting the 'real' default . We should be able to get rid of
# this block when we remove ` manage_redhat_firewall` .
2013-01-17 02:52:11 +01:00
if ( $ open_ssl_port ! = undef) {
$f inal_open_ssl_port = $ open_ssl_port
} else {
$f inal_open_ssl_port = true
}
2012-09-20 23:46:26 +02:00
2012-11-13 21:38:38 +01:00
if ( $ open_ssl_port or $ manage_redhat_firewall) {
2012-11-29 14:46:05 +01:00
if ( $ ssl_port) {
$f inal_ssl_port = $ ssl_port
} else {
$f inal_ssl_port = $ port
}
firewall { "${final_ssl_port} accept - puppetdb" :
port = > $f inal_ssl_port,
2012-11-13 21:38:38 +01:00
proto = > 'tcp' ,
action = > 'accept' ,
}
2012-09-20 23:46:26 +02:00
}
2012-09-18 02:06:48 +02:00
}
}