Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/adblockplus/manifests/web/mimeo.pp

Issue 29504594: #2687 - Include mimeo python module (Closed)
Patch Set: For comment 11 Created Aug. 8, 2017, 2:48 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(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":
49 ensure => 'present',
50 owner => 'root',
51 group => 'root',
52 mode => 0644,
53 content => file('adblockplus/mimeo.py'),
54 require => File["/opt/mimeo"],
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'),
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 status mimeo.service | grep disabled',
mathias 2017/08/08 07:51:46 Why not use `systemctl is-enabled` for this test?
f.lopez 2017/08/09 19:50:48 Done.
73 require => File["/etc/systemd/system/mimeo.service"],
74 }
75
76 service {"mimeo.service":
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-daemons":
mathias 2017/08/08 07:51:46 This is a way too global operation to be placed in
f.lopez 2017/08/09 19:50:48 Done.
87 command => 'systemctl daemon-reload',
88 subscribe => File["/etc/systemd/system/mimeo.service"],
89 refreshonly => true,
90 }
91 }
92
OLDNEW

Powered by Google App Engine
This is Rietveld