Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # == Class: adblockplus:mumble | 1 # == Class: adblockplus:mumble |
2 # | 2 # |
3 # Create and maintain mumble (https://www.mumble.com) setups. | 3 # Create and maintain mumble (https://www.mumble.com) setups. |
4 # | 4 # |
5 # === Parameters: | 5 # === Parameters: |
6 # | 6 # |
7 # [*package*] | 7 # [*package*] |
8 # Overwrite the default package options, to fine-tune the target version (i.e. | 8 # Overwrite the default package options, to fine-tune the target version (i.e. |
9 # ensure => 'latest') or remove mumble (ensure => 'absent' or 'purged') | 9 # ensure => 'latest') or remove mumble (ensure => 'absent' or 'purged') |
10 # | |
11 # === Hiera (only) Parameters: | |
mathias
2017/08/24 06:23:07
Why Hiera only?
f.lopez
2017/08/25 19:04:40
Well, I wanted to use it with hiera only, but yeah
| |
12 # | 10 # |
13 # [*certificate*] | 11 # [*certificate*] |
14 # Certificate used to enable SSL connection with the server. | 12 # Certificate used to enable SSL connection with the server. |
15 # | 13 # |
16 # [*private_key*] | 14 # [*private_key*] |
17 # Private key used to enable SSL connection with the client. | 15 # Private key used to enable SSL connection with the client. |
18 # | 16 # |
19 # [*server_password*] | 17 # [*server_password*] |
20 # String used to login into the server. | 18 # String used to login into the server. |
21 # | 19 # |
22 # | 20 # |
23 # === Examples: | 21 # === Examples: |
24 # | 22 # |
25 # class {'adblockplus::mumble': | 23 # class {'adblockplus::mumble': |
26 # package => { | 24 # package => { |
27 # 'ensure' => 'absent', | 25 # 'ensure' => 'absent', |
28 # }, | 26 # }, |
29 # }, | 27 # }, |
30 # } | 28 # } |
31 # | 29 # |
32 class adblockplus::mumble ( | 30 class adblockplus::mumble ( |
33 $package = {}, | 31 $package = {}, |
32 $certificate = {}, | |
33 $private_key = {}, | |
34 $server_password = 'changeme', | |
34 ){ | 35 ){ |
35 | 36 |
36 if ensure_state($ensure) { | 37 # https://forge.puppet.com/puppetlabs/stdlib#getparam |
mathias
2017/08/24 06:23:07
The $ensure parameter is always undefined at this
f.lopez
2017/08/25 19:04:40
Acknowledged.
| |
37 $ensure = 'present' | 38 $package_ensure = $package['ensure'] |
39 | |
40 # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors | |
41 $ensure = $package_ensure ? { | |
42 /^(absent|latest|present|purged|true)$/ => $package_ensure, | |
43 default => 'present', | |
38 } | 44 } |
39 else { | |
40 $ensure = 'absent' | |
41 } | |
42 | |
43 $certificate = hiera('adblockplus::mumble::certificate', undef) | |
44 $private_key = hiera('adblockplus::mumble::private_key', undef) | |
45 $server_password = hiera('adblockplus::mumble::server_password', undef) | |
46 | 45 |
47 ensure_resource('package', $title, merge({ | 46 ensure_resource('package', $title, merge({ |
48 name => 'mumble-server', | 47 name => 'mumble-server', |
49 ensure => $ensure, | 48 ensure => $ensure, |
50 }, $package)) | 49 }, $package)) |
51 | 50 |
52 file{"/etc/mumble-server.ini": | 51 file {'/etc/mumble-server.ini': |
53 owner => 'root', | 52 owner => 'root', |
54 group => 'mumble-server', | 53 group => 'mumble-server', |
55 mode => 0640, | 54 mode => 0640, |
56 content => template('adblockplus/mumble-server.ini.erb'), | 55 content => template('adblockplus/mumble-server.ini.erb'), |
57 require => Package[$title], | 56 require => Package[$title], |
58 notify => Service['mumble-server'], | 57 notify => Service['mumble-server'], |
59 } | 58 } |
60 | 59 |
61 service{'mumble-server': | 60 service {'mumble-server': |
62 ensure => 'running', | 61 ensure => 'running', |
63 enable => true, | 62 enable => true, |
64 require => Package[$title], | 63 require => Package[$title], |
65 } | 64 } |
66 | 65 |
67 if $mumble::certificate and $mumble::private_key { | 66 # https://forge.puppet.com/puppetlabs/stdlib#getparam |
mathias
2017/08/24 06:23:07
Please do not replicate the legacy "give me the na
f.lopez
2017/08/25 19:04:40
Ok fair enough, working on this. Gonna send a new
| |
68 file {"/etc/mumble.crt": | 67 $certificate_ensure = $certificate['ensure'] |
69 ensure => 'file', | |
70 mode => 0644, | |
71 group => 'mumble-server', | |
72 before => File["/etc/mumble-server.ini"], | |
73 require => Package[$title], | |
74 source => "puppet:///modules/private/${mumble::certificate}", | |
75 } | |
76 | 68 |
77 file {"/etc/mumble.key": | 69 # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors |
78 ensure => 'file', | 70 $ensure_certificate = $certificate_ensure ? { |
79 mode => 0644, | 71 /^(absent|latest|present|purged|true)$/ => $certificate_ensure, |
80 group => 'mumble-server', | 72 default => 'absent', |
81 before => File["/etc/mumble-server.ini"], | |
82 require => Package[$title], | |
83 source => "puppet:///modules/private/${mumble::private_key}", | |
84 } | |
85 } | 73 } |
74 | |
75 $default_cert_source = $certificate['content'] ? { | |
76 undef => 'puppet:///modules/private/mumble.crt', | |
77 default => undef, | |
78 } | |
79 | |
80 ensure_resource('file', '/etc/mumble.crt', merge({ | |
81 ensure => ensure_file_state($ensure_certificate), | |
82 mode => 0644, | |
83 path => '/etc/mumble.crt', | |
84 group => 'mumble-server', | |
85 before => File['/etc/mumble-server.ini'], | |
86 require => Package[$title], | |
87 source => $default_cert_source, | |
88 }, $certificate)) | |
89 | |
90 # https://forge.puppet.com/puppetlabs/stdlib#getparam | |
91 $private_key_ensure = $private_key['ensure'] | |
92 | |
93 # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors | |
94 $ensure_private_key = $certificate_ensure ? { | |
95 /^(absent|latest|present|purged|true)$/ => $private_key_ensure, | |
96 default => 'absent', | |
97 } | |
98 | |
99 $default_pk_source = $private_key['content'] ? { | |
100 undef => 'puppet:///modules/private/mumble.key', | |
101 default => undef, | |
102 } | |
103 | |
104 ensure_resource('file', 'mumble.key', merge({ | |
105 ensure => ensure_file_state($ensure_private_key), | |
106 mode => 0644, | |
107 path => '/etc/mumble.key', | |
108 group => 'mumble-server', | |
109 before => File['/etc/mumble-server.ini'], | |
110 require => Package[$title], | |
111 source => $default_pk_source, | |
112 }, $private_key)) | |
86 } | 113 } |
87 | 114 |
LEFT | RIGHT |