Index: modules/sitescripts/manifests/formmail.pp |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/modules/sitescripts/manifests/formmail.pp |
@@ -0,0 +1,52 @@ |
+# == Class: sitescripts::formmail |
+# |
+# Manage formmail templates resources. |
+# |
+# === Parameters: |
+# |
+# [*directory*] |
+# Custom parameter for formmail templates' directory. |
+# |
+# [*ensure*] |
+# General target policy for Puppet resources, supported values include |
+# "present", "latest", "absent" and "purged" |
+# |
+# === Examples: |
+# |
+# filtermaster::repo_download {'exceptionrules': |
mathias
2018/03/07 17:44:17
The example section should either vanish or contai
f.lopez
2018/03/07 23:01:48
Acknowledged.
|
+# alias => 'exceptions', |
+# } |
+# |
+class sitescripts::formmail( |
+ $directory = {}, |
+ $ensure = 'present', |
+) { |
+ |
+ include sitescripts |
+ include stdlib |
+ include spawn_fcgi |
+ |
+ ensure_resource('file', $title, merge({ |
+ 'ensure' => ensure_directory_state($ensure), |
+ 'path' => "${::sitescripts::directory_path}/formmail", |
+ }, $directory)) |
+ |
+ $directory_path = getparam(File[$title], 'path') |
+ $templates_raw = hiera_hash('sitescripts::formmail::templates', {}) |
+ |
+ $templates = parsejson(inline_template('<%= require "json"; |
mathias
2018/03/07 17:44:17
I will be so happy when the 4.x / future parser re
f.lopez
2018/03/07 23:01:48
Well I'm working on http://hub.eyeo.com/issues/125
|
+ @templates_raw.map do |key, value| |
+ value["path"] ||= "#{@directory_path}/#{key}" |
+ ["#{@title}##{key}", value] |
+ end.to_h.to_json |
+ %>')) |
+ |
+ create_resources('file', $templates, { |
+ ensure => ensure_file_state($ensure), |
+ tag => 'formmail_template', |
+ notify => Service['spawn-fcgi'], |
+ }) |
+ |
+ File[$title] -> File<|tag == 'formmail_template' |> |
+ File[$title] <- File[$::sitescripts::title] |
+} |