File: drive_full_checker.pp

package info (click to toggle)
puppet-module-swift 25.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,400 kB
  • sloc: ruby: 9,593; python: 38; sh: 10; makefile: 10
file content (155 lines) | stat: -rw-r--r-- 5,870 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# == Class swift::storage::drive_full_checker
#
# Set up swift-drive-full-checker cron job
#
# == Parameters
#
# [*user*]
#   (Optional) User with access to swift files.
#   Defaults to $::swift::params::user.
#
# [*minute*]
#   (Optional) Defaults to '*/5'.
#
# [*log_facility*]
#   (Optional) Syslog log facility.
#   Defaults to 'LOG_LOCAL2'.
#
# [*log_level*]
#   (Optional) Logging level.
#   Defaults to 'INFO'.
#
# [*log_address*]
#   (Optional) Location where syslog sends the logs to.
#   Defaults to '/dev/log'.
#
# [*log_name*]
#   (Optional) Label used when logging.
#   Defaults to 'drive-full-checker'.
#
# [*log_udp_host*]
#   (Optional) If not set, the UDP receiver for syslog is disabled.
#   Defaults to undef.
#
# [*log_udp_port*]
#   (Optional) Port value for UDP receiver, if enabled.
#   Defaults to undef.
#
# [*device_dir*]
#   (Optional) Directory devices are mounted under
#   Defaults to $facts['os_service_default'].
#
# [*log_to_console*]
#   (Optional) Make drive-full-checker log to console in addition to syslog
#   Defaults to $facts['os_service_default'].
#
# [*account_max_connections*]
#   (Optional) Maximum number of rsync connections per drive for the account ring.
#   Default to 8.
#
# [*account_reserved_space*]
#   (Optional) Reserved space in GiB until when max connectiuons is set to -1
#   in rsyncd.conf for the account rsync module.
#   Default to 300.
#
# [*account_rsyncd_section_name*]
#   (Optional) Name of the rsync module template for accounts. The '{}' string will
#   be replaced by swift-drive-full-checker by the name of the drive.
#   Default to ' account_{} '.
#
# [*container_max_connections*]
#   (Optional) Maximum number of rsync connections per drive for the container ring.
#   Default to 8.
#
# [*container_reserved_space*]
#   (Optional) Reserved space in GiB until when max connectiuons is set to -1
#   in rsyncd.conf for the container rsync module.
#   Default to 300.
#
# [*container_rsyncd_section_name*]
#   (Optional) Name of the rsync module template for containers. The '{}' string will
#   be replaced by swift-drive-full-checker by the name of the drive.
#   Default to ' container_{} '.
#
# [*object_max_connections*]
#   (Optional) Maximum number of rsync connections per drive for the object ring.
#   Default to 8.
#
# [*object_reserved_space*]
#   (Optional) Reserved space in GiB until when max connectiuons is set to -1
#   in rsyncd.conf for the object rsync module.
#   Default to 300.
#
# [*object_rsyncd_section_name*]
#   (Optional) Name of the rsync module template for objects. The '{}' string will
#   be replaced by swift-drive-full-checker by the name of the drive.
#   Default to ' object_{} '.
#
class swift::storage::drive_full_checker(
  # cron options
  $user                          = $::swift::params::user,
  $minute                        = '*/5',
  # drive-full-checker.conf options
  $log_facility                  = 'LOG_LOCAL2',
  $log_level                     = 'INFO',
  $log_address                   = '/dev/log',
  $log_name                      = 'drive-full-checker',
  $log_udp_host                  = undef,
  $log_udp_port                  = undef,
  $device_dir                    = '/srv/node',
  $log_to_console                = $facts['os_service_default'],
  $account_max_connections       = 8,
  $account_reserved_space        = 100,
  $account_rsyncd_section_name   = ' account_{} ',
  $container_max_connections     = 8,
  $container_reserved_space      = 100,
  $container_rsyncd_section_name = ' container_{} ',
  $object_max_connections        = 8,
  $object_reserved_space         = 100,
  $object_rsyncd_section_name    = ' object_{} ',
) inherits swift::params {

  include swift::deps

  swift_drive_full_checker_config {
    'drive-full-checker/log_name'    : value => $log_name;
    'drive-full-checker/log_facility': value => $log_facility;
    'drive-full-checker/log_level'   : value => $log_level;
    'drive-full-checker/log_address' : value => $log_address;
  }

  if $log_udp_host {
    swift_drive_full_checker_config {
      'drive-full-checker/log_udp_host': value => $log_udp_host;
      'drive-full-checker/log_udp_port': value => pick($log_udp_port, $facts['os_service_default']);
    }
  } else {
    swift_drive_full_checker_config {
      'drive-full-checker/log_udp_host': value => $facts['os_service_default'];
      'drive-full-checker/log_udp_port': value => $facts['os_service_default'];
    }
  }

  swift_drive_full_checker_config {
    'drive-full-checker/user'                          : value => $user;
    'drive-full-checker/device_dir'                    : value => $device_dir;
    'drive-full-checker/log_to_console'                : value => $log_to_console;
    'drive-full-checker/account_max_connections'       : value => $account_max_connections;
    'drive-full-checker/account_reserved_space'        : value => $account_reserved_space;
    'drive-full-checker/account_rsyncd_section_name'   : value => $account_rsyncd_section_name;
    'drive-full-checker/container_max_connections'     : value => $container_max_connections;
    'drive-full-checker/container_reserved_space'      : value => $container_reserved_space;
    'drive-full-checker/container_rsyncd_section_name' : value => $container_rsyncd_section_name;
    'drive-full-checker/object_max_connections'        : value => $object_max_connections;
    'drive-full-checker/object_reserved_space'         : value => $object_reserved_space;
    'drive-full-checker/object_rsyncd_section_name'    : value => $object_rsyncd_section_name;
  }

  cron { 'swift-full-checker':
    command     => "swift-drive-full-checker --source-file /etc/swift/rsyncd.conf",
    environment => 'PATH=/bin:/sbin:/usr/bin:/usr/sbin SHELL=/bin/sh',
    user        => $user,
    minute      => $minute,
    require     => Anchor['swift::config::end'],
  }
}