Puppet Class: natlog

Defined in:
modules/natlog/manifests/init.pp

Summary

configures the natlog utility

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • base_path (Stdlib::Unixpath) (defaults to: '/srv/natlog')
  • logrotate_frequency (Logrotate::Frequency) (defaults to: 'daily')
  • logrotate_days (Integer[1]) (defaults to: 4)


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

class natlog (
    Stdlib::Unixpath             $base_path            = '/srv/natlog',
    Logrotate::Frequency         $logrotate_frequency = 'daily',
    Integer[1]                   $logrotate_days      = 4,
) {
    package { 'natlog':
        ensure => present,
    }

    systemd::tmpfile { 'natlog':
        content => "d ${base_path}/ 0755 root adm -",
    }

    $rotate = $logrotate_frequency ? {
        'hourly' => $logrotate_days * 24,
        default  => $logrotate_days,
    }

    file { '/etc/systemd/journald@natlog.conf':
        ensure => file,
        source => 'puppet:///modules/natlog/journald.conf',
    }

    logrotate::rule { 'natlog':
        ensure       => present,
        file_glob    => "${base_path}/natlog.log",
        frequency    => $logrotate_frequency,
        compress     => true,
        missing_ok   => true,
        not_if_empty => true,
        rotate       => $rotate,
        post_rotate  => ['/usr/lib/rsyslog/rsyslog-rotate'],
    }

    if debian::codename::eq('bullseye') {
        # This is no longer required in bookworm and newer.
        file_line { 'natlog_start':
            ensure  => present,
            path    => '/etc/default/natlog',
            line    => 'START=yes',
            match   => '^START',
            require => Package['natlog'],
            notify  => Service['natlog'],
        }
    }

    systemd::override { 'natlog':
        unit   => 'natlog',
        source => 'puppet:///modules/natlog/natlog.override.service',
        before => Service['natlog'],
    }

    service { 'natlog':
        ensure  => running,
        enable  => true,
        require => Package['natlog'],
    }

    rsyslog::conf { 'natlog':
        content  => template('natlog/rsyslog.conf.erb'),
        priority => 20,
        require  => [Systemd::Tmpfile['natlog'], Service['natlog']],
    }
}