Index: modules/adblockplus/manifests/web/mimeo.pp |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/modules/adblockplus/manifests/web/mimeo.pp |
@@ -0,0 +1,92 @@ |
+# == Class: adblockplus::web::mimeo |
+# |
+# A [mimeograph](https://en.wikipedia.org/wiki/Mimeograph) (also known as stencil duplicator) is a low-cost duplicating |
+# machine. Mimeo is used here since it is the abbreviation and it sounds better. |
+# |
+# The pourpose of this class is to log the information received in a http/s |
+# petition with an specified format. |
+# === Parameters: |
+# |
+# [*format*] |
+# A systemd escaped string containing the desired format for logging. |
+# |
+# '$remote_addr - - [$time_local] "$request" $status $bytes_sent "$http_referer"' |
+# |
+# This is an example of how the format would look like in the log file. |
+# |
+# \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 |
+# |
+# And this is how it looks escaped, for escaping is necessary to use |
+# `systemd-escape` command, since this parameter is passed to a systemd |
+# unit file. |
+# |
+# [*port*] |
+# An integer to setup the port where the script will be listening, defaults |
+# to 8000. |
+# |
+# [*response*] |
+# A systemd escaped string (like format parameter) representing the response |
+# sent to the client. |
+# |
+# [*log_file*] |
+# A string containg the path to the file where the logs will be written. |
+class adblockplus::web::mimeo ( |
+ $format = '', |
+ $port = 8000, |
+ $response = '', |
+ $log_file = '/var/log/mimeo.py', |
Fred
2017/08/04 15:20:36
Isn't .py a confusing line ending for a log file?
f.lopez
2017/08/04 16:01:10
My bad, I actually meant `.log` instead of `.py`
|
+){ |
+ |
+ ensure_packages(['python3']) |
+ |
+ file {"/opt/mimeo": |
+ ensure => 'directory', |
+ owner => 'root', |
+ group => 'root', |
+ } |
+ |
+ file {"/opt/mimeo/mimeo.py": |
+ ensure => 'present', |
+ owner => 'root', |
+ group => 'root', |
+ mode => 0644, |
+ content => file('adblockplus/mimeo.py'), |
+ require => File["/opt/mimeo"], |
+ } |
+ |
+ file {"/etc/systemd/system/mimeo.service": |
+ ensure => 'present', |
+ owner => 'root', |
+ group => 'root', |
+ mode => 0644, |
+ content => template('adblockplus/mimeo.service.erb'), |
+ } |
+ |
+ Exec{ |
+ path => ['/usr/bin', '/bin'], |
+ } |
+ |
+ exec {"enable-service-mimeo": |
+ command => 'systemctl enable mimeo.service', |
+ user => 'root', |
+ onlyif => 'systemctl status mimeo.service | grep disabled', |
+ require => File["/etc/systemd/system/mimeo.service"], |
+ } |
+ |
+ service {"mimeo.service": |
+ ensure => 'running', |
+ hasrestart => false, |
+ provider => 'systemd', |
+ require => [ |
+ Exec["enable-service-mimeo"], |
+ Package["python3"], |
+ ], |
+ } |
+ |
+ exec {"reload-daemons": |
+ command => 'systemctl daemon-reload', |
+ subscribe => File["/etc/systemd/system/mimeo.service"], |
+ refreshonly => true, |
+ } |
+} |
+ |