Puppet Class: consul_template::logrotate

Defined in:
manifests/logrotate.pp

Overview

Class consul_template::logrotate

Parameters:

  • logrotate_compress (Any) (defaults to: $consul_template::logrotate_compress)
  • logrotate_files (Any) (defaults to: $consul_template::logrotate_files)
  • logrotate_on (Any) (defaults to: $consul_template::logrotate_on)
  • logrotate_period (Any) (defaults to: $consul_template::logrotate_period)
  • restart_sysv (String) (defaults to: '/sbin/service consul-template restart')
  • restart_systemd (String) (defaults to: '/bin/systemctl restart consul-template.service')


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
# File 'manifests/logrotate.pp', line 3

class consul_template::logrotate(
  $logrotate_compress     = $consul_template::logrotate_compress,
  $logrotate_files        = $consul_template::logrotate_files,
  $logrotate_on           = $consul_template::logrotate_on,
  $logrotate_period       = $consul_template::logrotate_period,
  String $restart_sysv    = '/sbin/service consul-template restart',
  String $restart_systemd = '/bin/systemctl restart consul-template.service',
) {

  case $facts['os']['family'] {
    'RedHat': {
      case $facts['os']['name'] {
        'RedHat', 'CentOS', 'OracleLinux', 'Scientific': {
          if(versioncmp($facts['os']['release']['major'], '7') > 0) {
            $postrotate_command = $restart_systemd
          }
          elsif (versioncmp($facts['os']['release']['major'], '7') < 0) {
            $postrotate_command = $restart_sysv
          }
          else {
            $postrotate_command = $restart_systemd
          }
        }
        'Amazon': {
          $postrotate_command = $restart_sysv
        }
        default: {
          $postrotate_command = $restart_sysv
        }
      }
    }
    default: {
      $postrotate_command = $restart_sysv
    }
  }

  if $logrotate_on {
    file { '/etc/logrotate.d/consul-template':
      ensure  => file,
      content => template("${module_name}/consul-template.logrotate.erb"),
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
    }
  }

}