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

Unified Diff: modules/adblockplus/manifests/web/mimeo.pp

Issue 29504594: #2687 - Include mimeo python module (Closed)
Patch Set: For comments 28 to 30 Created Aug. 16, 2017, 4:14 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: modules/adblockplus/manifests/web/mimeo.pp
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/adblockplus/manifests/web/mimeo.pp
@@ -0,0 +1,79 @@
+# == 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.
mathias 2017/08/18 08:47:44 Please don't explain naming unless absolutely nece
f.lopez 2017/08/19 00:51:01 Done.
+#
+# 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.
+# petition with an specified format.
+# === 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.
+#
+# [*format*]
+# A string containing the desired format for logging.
+#
+# '$remote_addr - - [$time_local] "$request" $status $bytes_sent "$http_referer"'
+#
+# [*port*]
+# An integer to setup the port where the script will be listening, defaults
+# to 8000.
+#
+# [*response*]
+# A 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 (
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.
+ $format = '',
+ $port = 8000,
+ $response = '',
+ $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)
+){
+
+ ensure_packages(['python3'])
+
+ file {"/usr/local/bin/mimeo.py":
+ ensure => 'present',
+ owner => 'root',
+ group => 'root',
+ mode => 0755,
+ content => file('adblockplus/mimeo.py'),
mathias 2017/08/18 08:47:46 Why use $content/file() here instead of $source?
+ require => Package['python3'],
+ }
+
+ file {"/etc/systemd/system/mimeo.service":
+ ensure => 'present',
+ owner => 'root',
+ group => 'root',
+ mode => 0644,
+ content => template('adblockplus/mimeo.service.erb'),
+ require => File['/usr/local/bin/mimeo.py'],
+ }
+
+ Exec{
+ path => ['/usr/bin', '/bin'],
+ }
+
+ exec {"enable-service-mimeo":
+ command => 'systemctl enable mimeo.service',
+ user => 'root',
+ unless => 'systemctl is-enabled mimeo.service',
+ require => File["/etc/systemd/system/mimeo.service"],
+ }
+
+ service {"mimeo":
+ ensure => 'running',
+ hasrestart => false,
+ provider => 'systemd',
+ require => [
+ Exec["enable-service-mimeo"],
+ 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.
+ ],
+ }
+
+ exec {"reload-mimeo-daemon":
+ 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
+ subscribe => File["/etc/systemd/system/mimeo.service"],
+ refreshonly => true,
+ }
+}
+

Powered by Google App Engine
This is Rietveld