From a1d70fb4ab4118e50e9db09dc5d86cc5221b41c0 Mon Sep 17 00:00:00 2001 From: 12ww1160 <12ww1160@confdroid.com> Date: Tue, 21 Jul 2026 13:25:48 +0200 Subject: [PATCH] OP#647 initial commit after fork --- .gitignore | 2 ++ .vscode/settings.json | 4 +++- Jenkinsfile | 36 ++++++++++++++++++++++------ README.md | 49 +++++++++++++++++++++++++-------------- manifests/init.pp | 12 +++++----- manifests/main/config.pp | 14 +++++------ manifests/main/dirs.pp | 14 +++++------ manifests/main/files.pp | 20 ++++++++-------- manifests/main/install.pp | 18 +++++++------- manifests/main/service.pp | 12 +++++----- manifests/main/yumrepo.pp | 12 +++++----- manifests/params.pp | 22 +++++++++--------- 12 files changed, 128 insertions(+), 87 deletions(-) diff --git a/.gitignore b/.gitignore index a356406..ae5ef54 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ Gemfile.lock FileList .scannerwork +.vscode +.puppet-lint.rc \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 327ddd3..54b2f27 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,8 @@ "missingok", "postrotate", "sharedscripts", - "syslogs" + "syslogs", + "userpass", + "yumrepo" ] } \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 9579fc7..683a7bf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,7 +69,7 @@ pipeline { withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) { sh ''' /opt/sonar-scanner/bin/sonar-scanner \ - -Dsonar.projectKey=alloy_cd \ + -Dsonar.projectKey=confdroid_alloy \ -Dsonar.sources=. \ -Dsonar.host.url=https://sonarqube.confdroid.com \ -Dsonar.token=$SONAR_TOKEN @@ -90,16 +90,38 @@ pipeline { sh ''' git config user.name "Jenkins Server" git config user.email jenkins@confdroid.com + git rm -r --cached .vscode || echo "No .vscode to remove from git" git add -A && git commit -am "Recommit for updates in build $BUILD_NUMBER" || echo "No changes to commit" - git push -o merge_request.create \ - -o merge_request.target=master \ - -o merge_request.title="Auto-merge for build $BUILD_NUMBER" \ - -o merge_request.description="Automated changes from Jenkins build $BUILD_NUMBER" \ - -o merge_request.merge_when_pipeline_succeeds=true \ - origin jenkins-build-$BUILD_NUMBER + git push origin HEAD:master ''' } } } + stage('Mirror to Gitea') { + steps { + sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) { + withCredentials([usernamePassword( + credentialsId: 'Jenkins-gitea', + usernameVariable: 'GITEA_USER', + passwordVariable: 'GITEA_TOKEN')]) { + script { + // Checkout from GitLab (already done implicitly) + sh ''' + git checkout master + git pull origin master + git branch -D development + git branch -D jenkins-build-$BUILD_NUMBER + git rm -f Jenkinsfile + git rm -r --cached .vscode || echo "No .vscode to remove from git" + git commit --amend --no-edit --allow-empty + git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_alloy.git + git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ + push master --mirror + ''' + } + } + } + } + } } } \ No newline at end of file diff --git a/README.md b/README.md index afc29ab..2d66a73 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,26 @@ # Readme -[![Build Status](https://jenkins.confdroid.com/buildStatus/icon?job=alloy_cd)](https://jenkins.confdroid.com/job/alloy_cd/) +[![Build Status](https://jenkins.confdroid.com/buildStatus/icon?job=confdroid_alloy&style=plastic)](https://jenkins.confdroid.com/job/confdroid_alloy/) -[[_TOC_]] +- [Readme](#readme) + - [Synopsis](#synopsis) + - [WARNING](#warning) + - [Features](#features) + - [Repo Documentation](#repo-documentation) + - [Dependencies](#dependencies) + - [Deployment](#deployment) + - [SELINUX](#selinux) + - [Known Problems](#known-problems) + - [Support](#support) + - [Tests](#tests) + - [Contact Us](#contact-us) + - [Disclaimer](#disclaimer) ## Synopsis Grafana Alloy is a log management agent built by Grafana labs to scrape and forward logs to Loki, a log management system also built by Grafana labs. Then you can use Grafana itself to visualize those logs and built an alerting system. -`alloy_cd` is a Puppet module to automate installation and configuration of alloy. +`confdroid_alloy` is a Puppet module to automate installation and configuration of alloy. ## WARNING @@ -18,13 +30,13 @@ Grafana Alloy is a log management agent built by Grafana labs to scrape and forw INSTALLATION -* installs alloy binaries +- installs alloy binaries CONFIGURATION -* manage directories and files including templates -* manages the main alloy jenkins for loki and prometheus -* manage service +- manage directories and files including templates +- manages the main alloy jenkins for loki and prometheus +- manage service ## Repo Documentation @@ -36,17 +48,17 @@ All dependencies must be included in the catalogue. ## Deployment -* native Puppet deployment +- native Puppet deployment via site.pp or nodes.pp ```bash node 'example.example.net' { - include cd_kubernetes + include confdroid_alloy } ``` -* through Foreman: +- through Foreman: In order to apply parameters through Foreman, the params.pp must be added to the host or host group in question. @@ -60,19 +72,22 @@ All files and directories are configured with correct selinux context. If selinu ## Support -* OS: Rocky 9 -* Puppet 6,8 +- OS: Rocky 9 +- Puppet 8 ## Tests -* Puppet Lint -* Puppet Parser -* ERB Template Parser -* Sonar Quality Gate +- Puppet Lint + - excluded tests: + - `--no-variable_scope-check`: not applicable as we are inheriting parameters from params class. the lint check does not distinguish between facts and inherited parameters. +- Puppet Parser +- ERB Template Parser +- Sonar Quality Gate ## Contact Us -[contact Us](https://confdroid.com/contact/) +- [contact Us](https://confdroid.com/contact/) +- [Feedback Portal](https://feedback.confdroid.com) ## Disclaimer diff --git a/manifests/init.pp b/manifests/init.pp index d083d7f..75cdc5f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,8 +1,8 @@ -## alloy_cd::init.pp -# Module name: alloy_cd -# Author: Arne Teuke (arne_teuke@confdroid.com) -# @summary Class initializes the alloy_cd module. +## confdroid_alloy::init.pp +# Module name: confdroid_alloy +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary Class initializes the confdroid_alloy module. ############################################################################## -class alloy_cd { - include alloy_cd::params +class confdroid_alloy { + include confdroid_alloy::params } diff --git a/manifests/main/config.pp b/manifests/main/config.pp index 90bca00..cb39fa2 100644 --- a/manifests/main/config.pp +++ b/manifests/main/config.pp @@ -1,10 +1,10 @@ -#### alloy_cd::main::config.pp -# Module name: alloy_cd -# Author: Arne Teuke (arne_teuke@confdroid.com) -# @summary Class manages module logic for the alloy_cd module +#### confdroid_alloy::main::config.pp +# Module name: confdroid_alloy +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary Class manages module logic for the confdroid_alloy module ############################################################################### -class alloy_cd::main::config ( +class confdroid_alloy::main::config ( -) inherits alloy_cd::params { - include alloy_cd::main::service +) inherits confdroid_alloy::params { + include confdroid_alloy::main::service } diff --git a/manifests/main/dirs.pp b/manifests/main/dirs.pp index 07a6474..3b94bcd 100644 --- a/manifests/main/dirs.pp +++ b/manifests/main/dirs.pp @@ -1,12 +1,12 @@ -## alloy_cd::main::dirs.pp -# Module name: alloy_cd -# Author: Arne Teuke (arne_teuke@confdroid.com) -# @summary Class manages required directories for the alloy_cd module +## confdroid_alloy::main::dirs.pp +# Module name: confdroid_alloy +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary Class manages required directories for the confdroid_alloy module ############################################################################### -class alloy_cd::main::dirs ( +class confdroid_alloy::main::dirs ( -) inherits alloy_cd::params { - require alloy_cd::main::install +) inherits confdroid_alloy::params { + require confdroid_alloy::main::install # main config dir file { $ay_main_dir: diff --git a/manifests/main/files.pp b/manifests/main/files.pp index ebaf02d..2e07f3c 100644 --- a/manifests/main/files.pp +++ b/manifests/main/files.pp @@ -1,15 +1,15 @@ -## alloy_cd::main::files.pp -# Module name: alloy_cd -# Author: Arne Teuke (arne_teuke@confdroid.com) -# @summary Class manages required config files for the alloy_cd module +## confdroid_alloy::main::files.pp +# Module name: confdroid_alloy +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary Class manages required config files for the confdroid_alloy module ############################################################################### -class alloy_cd::main::files ( +class confdroid_alloy::main::files ( -) inherits alloy_cd::params { - require alloy_cd::main::dirs +) inherits confdroid_alloy::params { + require confdroid_alloy::main::dirs # Ensure log_targets is always an array - $log_targets_array = Array($alloy_cd::params::ay_log_targets, true) + $log_targets_array = Array($confdroid_alloy::params::ay_log_targets, true) file { $ay_main_file: ensure => file, @@ -20,7 +20,7 @@ class alloy_cd::main::files ( selrole => object_r, seltype => etc_t, seluser => system_u, - content => template('alloy_cd/config.alloy.erb'), + content => template('confdroid_alloy/config.alloy.erb'), notify => Service[$ay_service], } @@ -34,7 +34,7 @@ class alloy_cd::main::files ( selrole => object_r, seltype => etc_t, seluser => system_u, - content => template('alloy_cd/logrotate.rsyslog.erb'), + content => template('confdroid_alloy/logrotate.rsyslog.erb'), } # manage log file group permissions diff --git a/manifests/main/install.pp b/manifests/main/install.pp index 223c385..4bebe3a 100644 --- a/manifests/main/install.pp +++ b/manifests/main/install.pp @@ -1,14 +1,14 @@ -## alloy_cd::main::install.pp -# Module name: alloy_cd -# Author: Arne Teuke (arne_teuke@confdroid.com) -# @summary Class installs packages for the alloy_cd module +## confdroid_alloy::main::install.pp +# Module name: confdroid_alloy +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary Class installs packages for the confdroid_alloy module ############################################################################### -class alloy_cd::main::install ( +class confdroid_alloy::main::install ( -) inherits alloy_cd::params { - require alloy_cd::main::yumrepo +) inherits confdroid_alloy::params { + require confdroid_alloy::main::yumrepo - package { $reqpackages: - ensure => $pkg_ensure, + package { $ay_reqpackages: + ensure => $ay_pkg_ensure, } } diff --git a/manifests/main/service.pp b/manifests/main/service.pp index 3ad9bdd..eeb9f08 100644 --- a/manifests/main/service.pp +++ b/manifests/main/service.pp @@ -1,12 +1,12 @@ -## alloy_cd::main::service.pp -# Module name: alloy_cd -# Author: Arne Teuke (arne_teuke@confdroid.com) +## confdroid_alloy::main::service.pp +# Module name: confdroid_alloy +# Author: 12ww1160 (12ww1160@confdroid.com) # @summary Class manages the alloy service ############################################################################### -class alloy_cd::main::service ( +class confdroid_alloy::main::service ( -) inherits alloy_cd::params { - require alloy_cd::main::files +) inherits confdroid_alloy::params { + require confdroid_alloy::main::files service { $ay_service: ensure => running, diff --git a/manifests/main/yumrepo.pp b/manifests/main/yumrepo.pp index 925cc53..220eff0 100644 --- a/manifests/main/yumrepo.pp +++ b/manifests/main/yumrepo.pp @@ -1,11 +1,11 @@ -## alloy_cd::main::yumrepo.pp -# Module name: alloy_cd -# Author: Arne Teuke (arne_teuke@confdroid.com) -# @summary class install yum repos for the alloy_cd module +## confdroid_alloy::main::yumrepo.pp +# Module name: confdroid_alloy +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary class install yum repos for the confdroid_alloy module ############################################################################## -class alloy_cd::main::yumrepo ( +class confdroid_alloy::main::yumrepo ( -) inherits alloy_cd::params { +) inherits confdroid_alloy::params { # test yumrepo { 'grafana': ensure => 'present', diff --git a/manifests/params.pp b/manifests/params.pp index e4030a7..ab09ab1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,8 +1,8 @@ -## alloy_cd::params.pp -# Module name: alloy_cd -# Author: Arne Teuke (arne_teuke@confdroid.com) -# @param [String] reqpackages which packages to install -# @param [String] pkg_ensure 'latest' or 'present' +## confdroid_alloy::params.pp +# Module name: confdroid_alloy +# Author: 12ww1160 (12ww1160@confdroid.com) +# @param [String] ay_reqpackages which packages to install +# @param [String] ay_pkg_ensure 'latest' or 'present' # @param [String] ay_loki_url the url where alloy will send logs to. # @param [String] ay_loki_username the username to logon to loki # @param [String] ay_loki_userpass the password to logon to loki @@ -12,15 +12,15 @@ # the node exporter (external) # @param [String] ay_prom_url the url where alloy will send metrics # @param [Array] ay_log_targets the logging targets -# @summary Class contains all parameters for the alloy_cd module. +# @summary Class contains all parameters for the confdroid_alloy module. ############################################################################## -class alloy_cd::params ( +class confdroid_alloy::params ( - String $reqpackages = 'alloy', - String $pkg_ensure = 'latest', + String $ay_reqpackages = 'alloy', + String $ay_pkg_ensure = 'latest', # loki - Boolean $ay_manage_loki = true, + Boolean $ay_manage_loki = true, String $ay_loki_url = 'https://loki.example.net/loki/api/v1/push', String $ay_loki_username = 'loki_user', String $ay_loki_userpass = 'loki_pass', @@ -44,5 +44,5 @@ class alloy_cd::params ( $ay_main_file = "${ay_main_dir}/config.alloy" # includes must be last - include alloy_cd::main::config + include confdroid_alloy::main::config }