Defined Type: udp2log::instance
- Defined in:
- modules/udp2log/manifests/instance.pp
Overview
SPDX-License-Identifier: Apache-2.0
Define udp2log::instance
Sets up a udp2log daemon instance.
Parameters
$port - Default 8420. $log_directory - Main location for log files.Default: /var/log/udp2log $logrotate - If true, sets up a logrotate file for files in
$log_directory. Default: true
$ensure - Either 'present' or 'absent'. Default: 'present' $monitor_processes - bool. Default: true $monitor_log_age - bool. Default: true $template_variables - arbitrary variable(s) for use in udp2log config
template file. Default: undef
$recv_queue - in KB. If unset, –recv-queue may be set to
/proc/sys/net/core/rmem_max.
$logrotate_template - Path to template file to use for logrotate. Default:
udp2log_logrotate.erb
$forward_messages - Whether to forward received messages to other hosts.
Default: false
$mirror_destinations - Mirror received packets onto these hosts, using $port
Default: undef
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 |
# File 'modules/udp2log/manifests/instance.pp', line 25
define udp2log::instance(
Wmflib::Ensure $ensure = present,
Stdlib::Port $port = 8420,
$log_directory = '/var/log/udp2log',
$logrotate = true,
$monitor_processes = true,
$monitor_log_age = true,
$template_variables = undef,
$recv_queue = '524288',
$logrotate_template = 'udp2log/logrotate_udp2log.erb',
$rotate = 1000,
$forward_messages = false,
$mirror_destinations = undef,
){
# This define requires that the udp2log class has
# been included. The udp2log class is parameterized,
# so we don't want to use the require statement here
# to make sure it is included. This just sets
# up the dependency.
Class['udp2log'] -> Udp2log::Instance[$title]
$instance_name = $name
# Default template (udp2log/logrotate_udp2log.erb) required killall command
# which comes from the psmisc package
ensure_packages(['psmisc', 'udplog'])
base::service_unit { "udp2log-${name}":
ensure => $ensure,
systemd => systemd_template('udp2log'),
subscribe => File["/etc/udp2log/${name}"],
require => File["/etc/udp2log/${name}"],
}
# the udp2log instance's filter config file
file { "/etc/udp2log/${name}":
mode => '0744',
owner => 'root',
group => 'root',
content => template("udp2log/filters.${name}.erb"),
}
# primary directory where udp2log log files will be stored.
file { [$log_directory, "${log_directory}/archive"]:
ensure => 'directory',
mode => '0755',
owner => 'udp2log',
group => 'udp2log',
}
$logrotation = $logrotate ? {
false => 'absent',
default => 'present',
}
# if the logs in $log_directory should be rotated
# then configure a logrotate.d script to do so.
logrotate::conf { "udp2log-${name}":
ensure => $logrotation,
content => template($logrotate_template),
}
firewall::service { "udp2log_instance_${port}":
proto => 'udp',
port => $port,
src_sets => ['DOMAIN_NETWORKS'],
}
# only set up instance monitoring if the monitoring scripts are installed
if $::udp2log::monitor {
# include monitoring for this udp2log instance.
udp2log::instance::monitoring { $name:
ensure => $ensure,
log_directory => $log_directory,
monitor_processes => $monitor_processes,
monitor_log_age => $monitor_log_age,
require => Service["udp2log-${name}"],
}
}
# udp2log lacks native ipv6 support, front it with with a socat v6 to v4 relay
package { 'socat':
ensure => $ensure,
}
systemd::service { 'udp2log-proxy-socat-6to4':
ensure => $ensure,
content => systemd_template('udp2log-proxy-socat-6to4'),
restart => true,
}
}
|