Defined Type: dumps::web::fetches::job

Defined in:
modules/dumps/manifests/web/fetches/job.pp

Overview

Define dumps::web::fetches

Regularly copies files from $source to $destination.

Parameters

ensure

Ensure status of systemd timer ensure => absent will not remove any existent data.

Parameters:

  • source (Any)
  • destination (Any)
  • delete (Any) (defaults to: true)
  • exclude (Any) (defaults to: undef)
  • user (Any) (defaults to: undef)
  • mailto (Any) (defaults to: 'ops-dumps@wikimedia.org')
  • hour (Any) (defaults to: '*')
  • minute (Any) (defaults to: '*')
  • month (Any) (defaults to: '*')
  • monthday (Any) (defaults to: '*')
  • weekday (Any) (defaults to: undef)
  • ensure (Any) (defaults to: 'present')


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'modules/dumps/manifests/web/fetches/job.pp', line 9

define dumps::web::fetches::job(
    $source,
    $destination,
    $delete      = true,
    $exclude     = undef,
    $user        = undef,
    $mailto      = 'ops-dumps@wikimedia.org',
    $hour        = '*',
    $minute      = '*',
    $month       = '*',
    $monthday    = '*',
    $weekday     = undef,
    $ensure      = 'present',
) {
    file { $destination:
        ensure => 'directory',
        owner  => $user,
        group  => 'root',
    }

    $delete_option = $delete ? {
        true    => '--delete',
        default => ''
    }

    $exclude_option = $exclude ? {
        undef   => '',
        default => " --exclude ${exclude}"
    }

    # The rsync options, and paths can be so complex to just parse to the systemd service, so
    # we'll need to wrap the command in a script, which the service can then run.
    file { "/usr/local/bin/dump-fetch-${title}.sh":
        ensure  => $ensure,
        owner   => $user,
        group   => 'root',
        mode    => '0554',
        content => template('dumps/rsync/run_rsync.erb'),
    }

    # Construct interval variable. The systemd calendar "parser" will complain about
    # * for weekdays.
    if ($weekday) {
        $interval = "${weekday} *-${month}-${monthday} ${hour}:${minute}:00"
    } else {
        $interval = "*-${month}-${monthday} ${hour}:${minute}:00"
    }

    systemd::timer::job { "dumps-fetch-${title}":
        ensure      => $ensure,
        description => "${title} rsync job",
        command     => "/usr/local/bin/dump-fetch-${title}.sh",
        user        => $user,
        environment => {'MAILTO' => $mailto},
        interval    => {'start' => 'OnCalendar', 'interval' => $interval},
    }
}