File: purge_deleted.pp

package info (click to toggle)
puppet-module-heat 25.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,560 kB
  • sloc: ruby: 3,889; python: 38; sh: 10; makefile: 10
file content (92 lines) | stat: -rw-r--r-- 2,842 bytes parent folder | download
1
2
3
4
5
6
7
8
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# == Class: heat::cron::purge_deleted
#
# Installs a cron job to purge db entries marked as deleted and older than $age.
# Default will be 1 day.
#
# === Parameters
#
#  [*ensure*]
#    (optional) Defaults to present.
#    Valid values are present, absent.
#
#  [*minute*]
#    (optional) Defaults to '1'.
#
#  [*hour*]
#    (optional) Defaults to '0'.
#
#  [*monthday*]
#    (optional) Defaults to '*'.
#
#  [*month*]
#    (optional) Defaults to '*'.
#
#  [*weekday*]
#    (optional) Defaults to '*'.
#
#  [*maxdelay*]
#    (optional) Seconds. Defaults to 0. Should be a positive integer.
#    Induces a random delay before running the cronjob to avoid running all
#    cron jobs at the same time on all hosts this job is configured.
#
#  [*user*]
#    (optional) User with access to heat files.
#    Defaults to $::heat::params::user.
#
#  [*age*]
#    (optional) Age value for $age_type.
#    Defaults to '1'.
#
#  [*age_type*]
#    (optional) Age type.
#    Can be days, hours, minutes, seconds
#    Defaults to 'days'.
#
#  [*destination*]
#    (optional) Path to file to which rows should be archived
#    Defaults to '/var/log/heat/heat-purge_deleted.log'.
#
#  [*batch_size*]
#    (optional) Number of stacks to delete at a time (per transaction).
#    Defaults to undef.
#
class heat::cron::purge_deleted (
  Enum['present', 'absent'] $ensure                     = present,
  $minute                                               = 1,
  $hour                                                 = 0,
  $monthday                                             = '*',
  $month                                                = '*',
  $weekday                                              = '*',
  Integer[0] $maxdelay                                  = 0,
  $user                                                 = $::heat::params::user,
  $age                                                  = 1,
  Enum['days', 'hours', 'minutes', 'seconds'] $age_type = 'days',
  $destination                                          = '/var/log/heat/heat-purge_deleted.log',
  $batch_size                                           = undef,
) inherits heat::params {

  if $maxdelay == 0 {
    $sleep = ''
  } else {
    $sleep = "sleep `expr \${RANDOM} \\% ${maxdelay}`; "
  }

  if $batch_size != undef {
    $batch_size_opt = "-b ${batch_size} "
  } else {
    $batch_size_opt = ''
  }

  cron { 'heat-manage purge_deleted':
    ensure      => $ensure,
    command     => "${sleep}heat-manage purge_deleted -g ${age_type} ${age} ${batch_size_opt}>>${destination} 2>&1",
    environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
    user        => $user,
    minute      => $minute,
    hour        => $hour,
    monthday    => $monthday,
    month       => $month,
    weekday     => $weekday,
    require     => Anchor['heat::dbsync::end']
  }
}