Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 # == Class: adblockplus::web::mimeo | |
2 # | |
3 # A [mimeograph](https://en.wikipedia.org/wiki/Mimeograph) (also known as stenci l duplicator) is a low-cost duplicating | |
4 # machine. Mimeo is used here since it is the abbreviation and it sounds better. | |
5 # | |
6 # The pourpose of this class is to log the information received in a http/s | |
7 # petition with an specified format. | |
8 # === Parameters: | |
9 # | |
10 # [*format*] | |
11 # A systemd escaped string containing the desired format for logging. | |
12 # | |
13 # '$remote_addr - - [$time_local] "$request" $status $bytes_sent "$http_refere r"' | |
14 # | |
15 # This is an example of how the format would look like in the log file. | |
16 # | |
17 # \x24remote_addr\x20\x2d\x20\x2d\x20\x5b\x24time_local\x5d\x20\x22\x24request \x22\x20\x24status\x20\x24bytes_sent\x20\x22\x24http_referer\x22 | |
18 # | |
19 # And this is how it looks escaped, for escaping is necessary to use | |
20 # `systemd-escape` command, since this parameter is passed to a systemd | |
21 # unit file. | |
22 # | |
23 # [*port*] | |
24 # An integer to setup the port where the script will be listening, defaults | |
25 # to 8000. | |
26 # | |
27 # [*response*] | |
28 # A systemd escaped string (like format parameter) representing the response | |
29 # sent to the client. | |
30 # | |
31 # [*log_file*] | |
32 # A string containg the path to the file where the logs will be written. | |
33 class adblockplus::web::mimeo ( | |
34 $format = '', | |
35 $port = 8000, | |
36 $response = '', | |
37 $log_file = '/var/log/mimeo.log', | |
38 ){ | |
39 | |
40 ensure_packages(['python3']) | |
41 | |
42 file {"/opt/mimeo": | |
43 ensure => 'directory', | |
44 owner => 'root', | |
45 group => 'root', | |
46 } | |
47 | |
48 file {"/opt/mimeo/mimeo.py": | |
mathias
2017/08/09 21:09:07
I don't think this requires an entire directory in
f.lopez
2017/08/10 19:06:34
Done.
| |
49 ensure => 'present', | |
50 owner => 'root', | |
51 group => 'root', | |
52 mode => 0644, | |
53 content => file('adblockplus/mimeo.py'), | |
54 require => File["/opt/mimeo"], | |
mathias
2017/08/09 21:09:07
I'd consider Package['python3'] a requirement of t
f.lopez
2017/08/10 19:06:35
Done.
| |
55 } | |
56 | |
57 file {"/etc/systemd/system/mimeo.service": | |
58 ensure => 'present', | |
59 owner => 'root', | |
60 group => 'root', | |
61 mode => 0644, | |
62 content => template('adblockplus/mimeo.service.erb'), | |
mathias
2017/08/09 21:09:07
I'd consider the mimeo.py script a requirement of
f.lopez
2017/08/10 19:06:35
Done.
| |
63 } | |
64 | |
65 Exec{ | |
66 path => ['/usr/bin', '/bin'], | |
67 } | |
68 | |
69 exec {"enable-service-mimeo": | |
70 command => 'systemctl enable mimeo.service', | |
71 user => 'root', | |
72 onlyif => 'systemctl is-enabled mimeo.service | grep disabled', | |
mathias
2017/08/09 21:09:07
You can use parameter $unless and avoid grep by re
f.lopez
2017/08/10 19:06:35
Done.
| |
73 require => File["/etc/systemd/system/mimeo.service"], | |
74 } | |
75 | |
76 service {"mimeo.service": | |
mathias
2017/08/09 21:09:07
Just call it Service['mimeo'] please, in Puppet th
f.lopez
2017/08/10 19:06:34
Done.
| |
77 ensure => 'running', | |
78 hasrestart => false, | |
79 provider => 'systemd', | |
80 require => [ | |
81 Exec["enable-service-mimeo"], | |
82 Package["python3"], | |
83 ], | |
84 } | |
85 | |
86 exec {"reload-mimeo-daemon": | |
87 command => 'systemctl daemon-reload', | |
88 subscribe => File["/etc/systemd/system/mimeo.service"], | |
89 refreshonly => true, | |
90 } | |
91 } | |
92 | |
OLD | NEW |