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 cron job. 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: undef)
  • minute (Any) (defaults to: undef)
  • month (Any) (defaults to: undef)
  • monthday (Any) (defaults to: undef)
  • 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
# 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        = undef,
    $minute      = undef,
    $month       = undef,
    $monthday    = undef,
    $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}"
    }

    cron { "dumps-fetch-${title}":
        ensure      => $ensure,
        # Run command via bash instead of sh so that $source can be fancier
        # wildcards or globs (e.g. /path/to/{dir1,dir1}/ok/data/ )
        command     => "bash -c '/usr/bin/rsync -rt ${delete_option}${exclude_option} --chmod=go-w ${source}/ ${destination}/'",
        environment => "MAILTO=${mailto}",
        user        => $user,
        require     => File[$destination],
        minute      => $minute,
        hour        => $hour,
        month       => $month,
        monthday    => $monthday,
        weekday     => $weekday,
    }
}