add configuration and service

This commit is contained in:
Arne Teuke
2025-02-24 13:24:45 +01:00
parent e3e349e6a8
commit 2374fc6137
4 changed files with 60 additions and 6 deletions

View File

@@ -9,4 +9,19 @@ class cd_alloy::main::files (
require cd_alloy::main::dirs require cd_alloy::main::dirs
# Ensure log_targets is always an array
$log_targets_array = Array($cd_alloy::params::ay_log_targets, true)
file { $ay_main_file:
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
selrange => s0,
selrole => object_r,
seltype => etc_t,
seluser => system_u,
content => template('cd_alloy/config.alloy.erb'),
}
} }

View File

@@ -9,4 +9,10 @@ class cd_alloy::main::service (
require cd_alloy::main::files require cd_alloy::main::files
service { $ay_service:
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
}
} }

View File

@@ -3,6 +3,8 @@
# Author: Arne Teuke (arne_teuke@confdroid.com) # Author: Arne Teuke (arne_teuke@confdroid.com)
# @param [string] reqpackages which packages to install # @param [string] reqpackages which packages to install
# @param [string] pkg_ensure 'latest' or 'present' # @param [string] pkg_ensure 'latest' or 'present'
# @param [string] ay_loki_username the username to logon to loki
# @param [string] ay_loki_userpass the password to logon to loki
# @summary Class contains all parameters for the cd_alloy module. # @summary Class contains all parameters for the cd_alloy module.
############################################################################## ##############################################################################
class cd_alloy::params ( class cd_alloy::params (
@@ -10,6 +12,11 @@ class cd_alloy::params (
$reqpackages = 'alloy', $reqpackages = 'alloy',
$pkg_ensure = 'latest', $pkg_ensure = 'latest',
# loki
$ay_loki_url = 'https://loki.example.net/loki/api/v1/push'
$ay_loki_username = '',
$ay_loki_userpass = '',
) { ) {
# service # service
@@ -18,6 +25,9 @@ $ay_service = 'alloy'
# dirs # dirs
$ay_main_dir = '/etc/alloy' $ay_main_dir = '/etc/alloy'
# files
$ay_main_file = "$(ay_main_dir)/config.alloy"
# includes must be last # includes must be last
include cd_alloy::main::config include cd_alloy::main::config

View File

@@ -0,0 +1,23 @@
logging {
level = "info"
format = "logfmt"
}
loki.source.file "system_logs" {
targets = [
<% @log_targets_array.each do |target| -%>
{__path__ = "<%= target %>"},
<% end -%>
]
forward_to = [loki.write.loki.receiver]
}
loki.write "loki" {
endpoint {
url = "https://loki.confdroid.com/loki/api/v1/push"
basic_auth {
username = "<%= @ay_loki_username %>"
password = "<%= @ay_loki_userpass %>"
}
}
}