reminder.pp 2.1 KB
Newer Older
1
2
# Set up a cronjob for a meeting

muri's avatar
muri committed
3
define tails::meeting::reminder (
4
5
  Tuple[Pattern[/.+@.+/], 1, default] $addresses,
  String $subject,
intrigeri's avatar
intrigeri committed
6
7
  String $template,
  Integer $day_of_month,
intrigeri's avatar
Lint    
intrigeri committed
8
9
10
  Enum['present', 'absent'] $ensure     = 'present',
  Tuple[Integer, 1, default] $reminders = [10],
  Pattern[/.+@.+/] $fromemailaddress    = 'noreply@tails.boum.org',
11
  Boolean $skip_friday_to_sunday        = false,
12
  Boolean $append_date_to_subject       = false,
13
14
  $cron_hour                            = 8,
  $cron_minute                          = 15,
15
  $months                               = '*',
16
  Optional[String] $append_web_page     = undef,
muri's avatar
muri committed
17
) {
18
19
20
21
22
23
24
25
26
27
28
29
30
31

  #
  # Sanity checks
  #

  validate_email_address($fromemailaddress)
  $addresses.each |String $address| {
    validate_email_address($address)
  }

  #
  # Resources
  #

32
33
  $reminders_str = join($reminders, ',')
  $addresses_str = join($addresses, ',')
muri's avatar
muri committed
34
35

  file { "${tails::meeting::homedir}/${template}":
36
    ensure => $ensure,
intrigeri's avatar
Lint    
intrigeri committed
37
    owner  => $tails::meeting::user,
muri's avatar
muri committed
38
39
40
41
    group  => 'root',
    mode   => '0600',
    source => "puppet:///modules/tails/meeting/${template}"
  }
42

43
44
45
46
47
  $skip_friday_to_sunday_arg = $skip_friday_to_sunday ? {
    true    => '--skip-friday-to-sunday',
    default => '',
  }

48
49
50
51
52
  $append_date_to_subject_arg = $append_date_to_subject ? {
    true    => '--append-date-to-subject',
    default => '',
  }

53
54
55
56
57
  $append_web_page_args = $append_web_page ? {
    undef   => '',
    default => "--append-web-page ${append_web_page}",
  }

58
  cron { "meeting-reminder-${name}":
59
    ensure  => $ensure,
60
    command => "'${tails::meeting::script_path}' --reminder '${reminders_str}' --addresses '${addresses_str}' --day '${day_of_month}' --from '${fromemailaddress}' --subject '${subject}' --template '${tails::meeting::homedir}/${template}' ${skip_friday_to_sunday_arg} ${append_date_to_subject_arg} ${append_web_page_args}", # lint:ignore:140chars -- command
61
    user    => $tails::meeting::user,
62
63
    hour    => $cron_hour,
    minute  => $cron_minute,
64
    month   => $months,
intrigeri's avatar
Lint    
intrigeri committed
65
66
67
68
    require => [
      Class['::tails::meeting'],
      File["${tails::meeting::homedir}/${template}"],
    ],
69
70
  }
}