Index: modules/adblockplus/manifests/mumble.pp |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/modules/adblockplus/manifests/mumble.pp |
@@ -0,0 +1,114 @@ |
+# == Class: adblockplus:mumble |
+# |
+# Create and maintain mumble (https://www.mumble.com) setups. |
+# |
+# === Parameters: |
+# |
+# [*package*] |
+# Overwrite the default package options, to fine-tune the target version (i.e. |
+# ensure => 'latest') or remove mumble (ensure => 'absent' or 'purged') |
+# |
+# [*certificate*] |
+# Certificate used to enable SSL connection with the server. |
+# |
+# [*private_key*] |
+# Private key used to enable SSL connection with the client. |
+# |
+# [*server_password*] |
+# String used to login into the server. |
+# |
+# |
+# === Examples: |
+# |
+# class {'adblockplus::mumble': |
+# package => { |
+# 'ensure' => 'absent', |
+# }, |
+# }, |
+# } |
+# |
+class adblockplus::mumble ( |
+ $package = {}, |
+ $certificate = {}, |
+ $private_key = {}, |
+ $server_password = 'changeme', |
+){ |
+ |
+ # https://forge.puppet.com/puppetlabs/stdlib#getparam |
+ $package_ensure = $package['ensure'] |
+ |
+ # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors |
+ $ensure = $package_ensure ? { |
+ /^(absent|latest|present|purged|true)$/ => $package_ensure, |
+ default => 'present', |
+ } |
+ |
+ ensure_resource('package', $title, merge({ |
+ name => 'mumble-server', |
+ ensure => $ensure, |
+ }, $package)) |
+ |
+ file {'/etc/mumble-server.ini': |
+ owner => 'root', |
+ group => 'mumble-server', |
+ mode => 0640, |
+ content => template('adblockplus/mumble-server.ini.erb'), |
+ require => Package[$title], |
+ notify => Service['mumble-server'], |
+ } |
+ |
+ service {'mumble-server': |
+ ensure => 'running', |
+ enable => true, |
+ require => Package[$title], |
+ } |
+ |
+ # https://forge.puppet.com/puppetlabs/stdlib#getparam |
+ $certificate_ensure = $certificate['ensure'] |
+ |
+ # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors |
+ $ensure_certificate = $certificate_ensure ? { |
+ /^(absent|latest|present|purged|true)$/ => $certificate_ensure, |
+ default => 'absent', |
+ } |
+ |
+ $default_cert_source = $certificate['content'] ? { |
+ undef => 'puppet:///modules/private/mumble.crt', |
+ default => undef, |
+ } |
+ |
+ ensure_resource('file', '/etc/mumble.crt', merge({ |
+ ensure => ensure_file_state($ensure_certificate), |
+ mode => 0644, |
+ path => '/etc/mumble.crt', |
+ group => 'mumble-server', |
+ before => File['/etc/mumble-server.ini'], |
+ require => Package[$title], |
+ source => $default_cert_source, |
+ }, $certificate)) |
+ |
+ # https://forge.puppet.com/puppetlabs/stdlib#getparam |
+ $private_key_ensure = $private_key['ensure'] |
+ |
+ # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors |
+ $ensure_private_key = $certificate_ensure ? { |
+ /^(absent|latest|present|purged|true)$/ => $private_key_ensure, |
+ default => 'absent', |
+ } |
+ |
+ $default_pk_source = $private_key['content'] ? { |
+ undef => 'puppet:///modules/private/mumble.key', |
+ default => undef, |
+ } |
+ |
+ ensure_resource('file', 'mumble.key', merge({ |
+ ensure => ensure_file_state($ensure_private_key), |
+ mode => 0644, |
+ path => '/etc/mumble.key', |
+ group => 'mumble-server', |
+ before => File['/etc/mumble-server.ini'], |
+ require => Package[$title], |
+ source => $default_pk_source, |
+ }, $private_key)) |
+} |
+ |