All checks were successful
Build / precommit (pull_request) Successful in 4m39s
- add module for victorialogs - add hieradata for vl insert/select/storage - manage packages, directories, services, etc - manage exporting metrics
80 lines
2.3 KiB
Puppet
80 lines
2.3 KiB
Puppet
class victorialogs::node (
|
|
Boolean $enable = false,
|
|
String $user = 'victorialogs',
|
|
String $group = 'victorialogs',
|
|
Boolean $manage_user = true,
|
|
Boolean $manage_service = true,
|
|
Array[String] $packages = ['victoria-logs', 'vlutils'],
|
|
Stdlib::Absolutepath $exec_path = '/usr/bin/victoria-logs',
|
|
Stdlib::Absolutepath $data_path = '/var/lib/victorialogs',
|
|
Stdlib::Absolutepath $vars_file = '/etc/default/victoria-logs',
|
|
Hash[String, Variant[String, Array[String]]] $options = {},
|
|
) {
|
|
|
|
# if enabled, manage this service
|
|
if $enable {
|
|
|
|
# install required packages
|
|
if $packages {
|
|
ensure_packages($packages, {ensure => 'installed'})
|
|
}
|
|
|
|
# manage the user/group
|
|
if $manage_user {
|
|
group { $group:
|
|
ensure => present,
|
|
}
|
|
|
|
user { $user:
|
|
ensure => present,
|
|
shell => '/usr/sbin/nologin',
|
|
groups => $group,
|
|
managehome => true,
|
|
}
|
|
}
|
|
|
|
# manage directories
|
|
file { [ $data_path ]:
|
|
ensure => directory,
|
|
owner => $user,
|
|
group => $group,
|
|
}
|
|
|
|
# manage environment options file
|
|
file { $vars_file:
|
|
ensure => file,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0644',
|
|
content => template('victorialogs/options.erb'),
|
|
}
|
|
|
|
# manage the systemd service
|
|
if $manage_service {
|
|
|
|
# manage the subscribed resources
|
|
if 'tls' in $options and $options['tls'] == 'true' {
|
|
if 'tlsCertFile' in $options and 'tlsKeyFile' in $options {
|
|
# tls option AND certs listed, subscribe to the options file and certs
|
|
$subscribe = [File[$vars_file],File[$options['tlsCertFile']], File[$options['tlsKeyFile']]]
|
|
}else{
|
|
# tls option but no certs listed, just subscribe to the options file
|
|
warning('TLS is enabled but tlsCertFile or tlsKeyFile is missing from victorialogs options.')
|
|
$subscribe = [File[$vars_file]]
|
|
}
|
|
}else{
|
|
# no tls option, just subscribe to the options file
|
|
$subscribe = [File[$vars_file]]
|
|
}
|
|
|
|
# Use these in notifications or file resources
|
|
systemd::unit_file { 'victorialogs.service':
|
|
content => template('victorialogs/victorialogs.service.erb'),
|
|
enable => true,
|
|
active => true,
|
|
subscribe => $subscribe,
|
|
}
|
|
}
|
|
}
|
|
}
|