LEFT | RIGHT |
(no file at all) | |
| 1 # == Class: sitescripts::formmail |
| 2 # |
| 3 # Manage formmail templates resources. |
| 4 # |
| 5 # === Parameters: |
| 6 # |
| 7 # [*directory*] |
| 8 # Custom parameter for formmail templates' directory. |
| 9 # |
| 10 # [*ensure*] |
| 11 # General target policy for Puppet resources, supported values include |
| 12 # "present", "latest", "absent" and "purged" |
| 13 # |
| 14 class sitescripts::formmail( |
| 15 $directory = {}, |
| 16 $ensure = 'present', |
| 17 ) { |
| 18 |
| 19 include sitescripts |
| 20 include stdlib |
| 21 include spawn_fcgi |
| 22 |
| 23 ensure_resource('file', $title, merge({ |
| 24 'ensure' => ensure_directory_state($ensure), |
| 25 'path' => "${::sitescripts::directory_path}/formmail", |
| 26 }, $directory)) |
| 27 |
| 28 $directory_path = getparam(File[$title], 'path') |
| 29 $templates_raw = hiera_hash('sitescripts::formmail::templates', {}) |
| 30 |
| 31 $templates = parsejson(inline_template('<%= require "json"; |
| 32 @templates_raw.map do |key, value| |
| 33 value["path"] ||= "#{@directory_path}/#{key}" |
| 34 ["#{@title}##{key}", value] |
| 35 end.to_h.to_json |
| 36 %>')) |
| 37 |
| 38 create_resources('file', $templates, { |
| 39 ensure => ensure_file_state($ensure), |
| 40 tag => 'formmail_template', |
| 41 notify => Service['spawn-fcgi'], |
| 42 }) |
| 43 |
| 44 File[$title] -> File<|tag == 'formmail_template' |> |
| 45 File[$title] <- File[$::sitescripts::title] |
| 46 } |
LEFT | RIGHT |