Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # == Class: adblockplus::web::mimeo | 1 # == Class: adblockplus::web::mimeo |
2 # | 2 # |
3 # A [mimeograph](https://en.wikipedia.org/wiki/Mimeograph) (also known as stenci l duplicator) is a low-cost duplicating | 3 # Class adblockplus::web::mimeo registers the information received in a |
4 # machine. Mimeo is used here since it is the abbreviation and it sounds better. | 4 # http/s petition with an specified format in an specific output. |
mathias
2017/08/18 08:47:44
Please don't explain naming unless absolutely nece
f.lopez
2017/08/19 00:51:01
Done.
| |
5 # | 5 # |
6 # The pourpose of this class is to log the information received in a http/s | |
mathias
2017/08/18 08:47:45
Please name the item the fuzz is about and avoid n
f.lopez
2017/08/19 00:51:02
Done.
| |
7 # petition with an specified format. | |
8 # === Parameters: | 6 # === Parameters: |
mathias
2017/08/18 08:47:46
There should be a `#`-only line above this one.
f.lopez
2017/08/19 00:51:02
Done.
| |
9 # | 7 # |
10 # [*format*] | 8 # [*format*] |
11 # A string containing the desired format for logging. | 9 # A string containing the desired format for logging. |
12 # | 10 # |
13 # '$remote_addr - - [$time_local] "$request" $status $bytes_sent "$http_refere r"' | 11 # '$remote_addr - - [$time_local] "$request" $status $bytes_sent "$http_refere r"' |
14 # | 12 # |
15 # [*port*] | 13 # [*port*] |
16 # An integer to setup the port where the script will be listening, defaults | 14 # An integer to setup the port where the script will be listening, defaults |
17 # to 8000. | 15 # to 8000. |
18 # | 16 # |
19 # [*response*] | 17 # [*response*] |
20 # A string (like format parameter) representing the response sent to the | 18 # A string (like format parameter) representing the response sent to the |
21 # client. | 19 # client. |
22 # | 20 # |
23 # [*log_file*] | |
24 # A string containg the path to the file where the logs will be written. | |
25 class adblockplus::web::mimeo ( | 21 class adblockplus::web::mimeo ( |
mathias
2017/08/18 08:47:45
There should be a `#`-only line above this one as
f.lopez
2017/08/19 00:51:02
Done.
| |
26 $format = '', | 22 $format = '', |
27 $port = 8000, | 23 $port = 8000, |
28 $response = '', | 24 $response = '', |
29 $log_file = '/var/log/mimeo.log', | |
mathias
2017/08/18 08:47:44
Again this is not logging in the word's sense with
f.lopez
2017/08/19 00:51:01
I'll just default it to '-' (stdout)
| |
30 ){ | 25 ){ |
26 include adblockplus | |
31 | 27 |
32 ensure_packages(['python3']) | 28 ensure_packages(['python3']) |
33 | 29 |
34 file {"/usr/local/bin/mimeo.py": | 30 realize(File['/var/adblockplus']) |
31 | |
32 file {'/var/adblockplus/mimeo': | |
33 ensure => 'directory', | |
34 mode => '0755', | |
35 owner => 'root', | |
36 require => File['/var/adblockplus'], | |
37 } | |
38 | |
39 file {'/usr/local/bin/mimeo.py': | |
35 ensure => 'present', | 40 ensure => 'present', |
36 owner => 'root', | 41 owner => 'root', |
37 group => 'root', | 42 group => 'root', |
38 mode => 0755, | 43 mode => 0755, |
39 content => file('adblockplus/mimeo.py'), | 44 source => 'puppet:///modules/adblockplus/mimeo.py', |
mathias
2017/08/18 08:47:46
Why use $content/file() here instead of $source?
| |
40 require => Package['python3'], | 45 require => Package['python3'], |
41 } | 46 } |
42 | 47 |
43 file {"/etc/systemd/system/mimeo.service": | 48 file {'/etc/systemd/system/mimeo.service': |
44 ensure => 'present', | 49 ensure => 'present', |
45 owner => 'root', | 50 owner => 'root', |
46 group => 'root', | 51 group => 'root', |
47 mode => 0644, | 52 mode => 0644, |
48 content => template('adblockplus/mimeo.service.erb'), | 53 content => template('adblockplus/mimeo.service.erb'), |
49 require => File['/usr/local/bin/mimeo.py'], | 54 require => File['/usr/local/bin/mimeo.py'], |
50 } | 55 } |
51 | 56 |
52 Exec{ | 57 Exec{ |
53 path => ['/usr/bin', '/bin'], | 58 path => ['/usr/bin', '/bin'], |
54 } | 59 } |
55 | 60 |
56 exec {"enable-service-mimeo": | 61 exec {'enable-service-mimeo': |
57 command => 'systemctl enable mimeo.service', | 62 command => 'systemctl enable mimeo.service', |
58 user => 'root', | 63 user => 'root', |
59 unless => 'systemctl is-enabled mimeo.service', | 64 unless => 'systemctl is-enabled mimeo.service', |
60 require => File["/etc/systemd/system/mimeo.service"], | 65 require => File['/etc/systemd/system/mimeo.service'], |
61 } | 66 } |
62 | 67 |
63 service {"mimeo": | 68 service {'mimeo': |
64 ensure => 'running', | 69 ensure => 'running', |
65 hasrestart => false, | 70 hasrestart => false, |
66 provider => 'systemd', | 71 provider => 'systemd', |
67 require => [ | 72 require => Exec['enable-service-mimeo'], |
68 Exec["enable-service-mimeo"], | 73 subscribe => File['/usr/local/bin/mimeo.py'], |
69 Package["python3"], | |
mathias
2017/08/18 08:47:46
The service should be able to rely on the script m
f.lopez
2017/08/19 00:51:02
Done.
| |
70 ], | |
71 } | 74 } |
72 | 75 |
73 exec {"reload-mimeo-daemon": | 76 exec {'reload-mimeo-daemon': |
77 notify => Service['mimeo'], | |
74 command => 'systemctl daemon-reload', | 78 command => 'systemctl daemon-reload', |
mathias
2017/08/18 08:47:45
Does daemon-reload include a service restart if ne
f.lopez
2017/08/19 00:51:01
Heh, you are right, I forgot to notify the service
| |
75 subscribe => File["/etc/systemd/system/mimeo.service"], | 79 subscribe => File['/etc/systemd/system/mimeo.service'], |
76 refreshonly => true, | 80 refreshonly => true, |
77 } | 81 } |
78 } | 82 } |
79 | 83 |
LEFT | RIGHT |