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

Unified Diff: modules/sitescripts/manifests/formmail.pp

Issue 29438564: #301 - Provision formmail templates with absolute paths (Closed)
Patch Set: For comments 7 and 8 Created March 7, 2018, 11:08 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
« no previous file with comments | « hiera/roles/web/acceptableads.yaml ('k') | modules/sitescripts/manifests/init.pp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/sitescripts/manifests/formmail.pp
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/sitescripts/manifests/formmail.pp
@@ -0,0 +1,46 @@
+# == 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"
+#
+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";
+ @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]
+}
« no previous file with comments | « hiera/roles/web/acceptableads.yaml ('k') | modules/sitescripts/manifests/init.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld