Compare commits

...

4 Commits

Author SHA1 Message Date
Jenkins Server
17c76e14ca Recommit for updates in build 31 2026-10-04 13:27:40 +02:00
Jenkins Server
d5f6a5ceeb Merge remote-tracking branch 'origin/master' into jenkins-build-31 2026-10-04 13:26:50 +02:00
097956676e OP#830 add nagios target 2026-10-04 13:26:33 +02:00
Jenkins Server
561462758d Recommit for updates in build 30 2026-10-04 12:20:51 +02:00
8 changed files with 198 additions and 141 deletions

127
Jenkinsfile vendored
View File

@@ -1,127 +0,0 @@
pipeline {
agent {
label 'puppet'
}
post {
always {
deleteDir() /* clean up our workspace */
}
success {
updateGitlabCommitStatus state: 'success'
}
failure {
updateGitlabCommitStatus state: 'failed'
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'support@confdroid.com', sendToIndividuals: true])
}
}
options {
gitLabConnection('gitlab.confdroid.com')
}
stages {
stage('pull master') {
steps {
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
sh '''
git config user.name "Jenkins Server"
git config user.email jenkins@confdroid.com
# Ensure we're on the development branch (triggered by push)
git checkout development
# Create jenkins branch from development
git checkout -b jenkins-build-$BUILD_NUMBER
# Optionally merge master into jenkins to ensure compatibility
git merge origin/master --no-ff || { echo "Merge conflict detected"; exit 1; }
'''
}
}
}
stage('puppet parser') {
steps {
sh '''for file in $(find . -iname \'*.pp\'); do
/opt/puppetlabs/bin/puppet parser validate --color false --render-as s --modulepath=modules $file || exit 1;
done;'''
}
}
stage('check templates') {
steps{
sh '''for file in $(find . -iname \'*.erb\');
do erb -P -x -T "-" $file | ruby -c || exit 1;
done;'''
}
}
stage('puppet-lint') {
steps {
sh '''/usr/local/bin/puppet-lint . \\
--no-variable_scope-check \\
|| { echo "Puppet lint failed"; exit 1; }
'''
}
}
stage('SonarScan') {
steps {
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
sh '''
/opt/sonar-scanner/bin/sonar-scanner \
-Dsonar.projectKey=confdroid_ntp \
-Dsonar.sources=. \
-Dsonar.host.url=https://sonarqube.confdroid.com \
-Dsonar.token=$SONAR_TOKEN
'''
}
}
}
stage('create Puppet documentation') {
steps {
sh '/opt/puppetlabs/bin/puppet strings'
}
}
stage('update repo') {
steps {
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
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 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_ntp.git
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
push master --mirror
'''
}
}
}
}
}
}
}

View File

@@ -119,9 +119,9 @@ class confdroid_ntp::main::config (
) inherits confdroid_ntp::params { ) inherits confdroid_ntp::params {
include confdroid_ntp::main::service include confdroid_ntp::main::service
# if $ay_manage_nagios == true { if $cy_manage_nagios == true {
# include confdroid_ntp::monitoring::target include confdroid_ntp::monitoring::target
# } }
}</pre> }</pre>
</td> </td>
</tr> </tr>

View File

@@ -123,7 +123,28 @@
25 25
26 26
27 27
28</pre> 28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49</pre>
</td> </td>
<td> <td>
<pre class="code"><span class="info file"># File 'manifests/main/files.pp', line 6</span> <pre class="code"><span class="info file"># File 'manifests/main/files.pp', line 6</span>
@@ -148,8 +169,29 @@ class confdroid_ntp::main::files (
} }
# drift file /var/lib/chrony/drift # drift file /var/lib/chrony/drift
file { $cy_drift_file:
ensure =&gt; file,
owner =&gt; &#39;chrony&#39;,
group =&gt; &#39;chrony&#39;,
mode =&gt; &#39;0644&#39;,
selrange =&gt; s0,
selrole =&gt; object_r,
seltype =&gt; chronyd_var_lib_t,
seluser =&gt; system_u,
}
# log rotation # log rotation
file { $cy_logrotate_file:
ensure =&gt; file,
owner =&gt; &#39;root&#39;,
group =&gt; &#39;root&#39;,
mode =&gt; &#39;0644&#39;,
selrange =&gt; s0,
selrole =&gt; object_r,
seltype =&gt; etc_t,
seluser =&gt; system_u,
content =&gt; template($cy_logrotate_erb),
}
}</pre> }</pre>
</td> </td>
</tr> </tr>

View File

@@ -104,7 +104,21 @@
6 6
7 7
8 8
9</pre> 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23</pre>
</td> </td>
<td> <td>
<pre class="code"><span class="info file"># File 'manifests/monitoring/target.pp', line 6</span> <pre class="code"><span class="info file"># File 'manifests/monitoring/target.pp', line 6</span>
@@ -112,6 +126,20 @@
class confdroid_ntp::monitoring::target ( class confdroid_ntp::monitoring::target (
) inherits confdroid_ntp::params { ) inherits confdroid_ntp::params {
if $cy_manage_nagios == true {
@@nagios_service { &quot;check_chronyd_${fqdn}&quot;:
check_command =&gt; &quot;check_nrpe!check_chronyd!${cy_procs_allowed}!chrony&quot;,
use =&gt; &#39;generic-service&#39;,
host_name =&gt; $fqdn,
notification_period =&gt; &#39;24x7&#39;,
service_description =&gt; &quot;${fqdn}_check_chronyd&quot;,
target =&gt; $cy_target_service,
owner =&gt; &#39;nagios&#39;,
group =&gt; &#39;nagios&#39;,
mode =&gt; &#39;0640&#39;,
contacts =&gt; $cy_target_contacts,
}
}
}</pre> }</pre>
</td> </td>
</tr> </tr>

View File

@@ -284,6 +284,78 @@
&mdash; &mdash;
<div class='inline'> <div class='inline'>
<p>Whether to use a local LAN server or external pool.</p> <p>Whether to use a local LAN server or external pool.</p>
</div>
</li>
<li>
<span class='name'>cy_manage_nagios</span>
<span class='type'>(<tt>Boolean</tt>)</span>
<em class="default">(defaults to: <tt>false</tt>)</em>
&mdash;
<div class='inline'>
<p>Whether to manage Nagios monitoring for the module.</p>
</div>
</li>
<li>
<span class='name'>cy_procs_allowed</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&#39;1&#39;</tt>)</em>
&mdash;
<div class='inline'>
<p>Number of allowed processes for the Nagios check.</p>
</div>
</li>
<li>
<span class='name'>cy_target_service</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&#39;/etc/nagios/conf.d/chronyd_service.cfg&#39;</tt>)</em>
&mdash;
<div class='inline'>
<p>Path to the Nagios service configuration file.</p>
</div>
</li>
<li>
<span class='name'>cy_target_contacts</span>
<span class='type'>(<tt>Array</tt>)</span>
<em class="default">(defaults to: <tt>[&#39;admin&#39;]</tt>)</em>
&mdash;
<div class='inline'>
<p>List of Nagios contacts for notifications.</p>
</div> </div>
</li> </li>
@@ -299,10 +371,6 @@
<pre class="lines"> <pre class="lines">
22
23
24
25
26 26
27 27
28 28
@@ -333,10 +401,23 @@
53 53
54 54
55 55
56</pre> 56
57
58
59
60
61
62
63
64
65
66
67
68
69</pre>
</td> </td>
<td> <td>
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 22</span> <pre class="code"><span class="info file"># File 'manifests/params.pp', line 26</span>
class confdroid_ntp::params ( class confdroid_ntp::params (
@@ -354,6 +435,12 @@ class confdroid_ntp::params (
String $cy_leapsectz = &#39;right/UTC&#39;, String $cy_leapsectz = &#39;right/UTC&#39;,
String $cy_loginfo = &#39;measurements statistics tracking&#39;, String $cy_loginfo = &#39;measurements statistics tracking&#39;,
# monitoring
Boolean $cy_manage_nagios = false,
String $cy_procs_allowed = &#39;1&#39;,
String $cy_target_service = &#39;/etc/nagios/conf.d/chronyd_service.cfg&#39;,
Array $cy_target_contacts = [&#39;admin&#39;],
) { ) {
# facts # facts
$fqdn = $facts[&#39;networking&#39;][&#39;fqdn&#39;] $fqdn = $facts[&#39;networking&#39;][&#39;fqdn&#39;]
@@ -366,6 +453,9 @@ class confdroid_ntp::params (
# files # files
$cy_conf_file = &#39;/etc/chrony.conf&#39; $cy_conf_file = &#39;/etc/chrony.conf&#39;
$cy_conf_erb = &#39;confdroid_ntp/chrony.conf.erb&#39; $cy_conf_erb = &#39;confdroid_ntp/chrony.conf.erb&#39;
$cy_drift_file = &#39;/var/lib/chrony/drift&#39;
$cy_logrotate_file = &#39;/etc/logrotate.d/chrony&#39;
$cy_logrotate_erb = &#39;confdroid_ntp/logrotate.chrony.erb&#39;
# service # service
$cy_service = &#39;chronyd&#39; $cy_service = &#39;chronyd&#39;

View File

@@ -8,7 +8,7 @@ class confdroid_ntp::main::config (
) inherits confdroid_ntp::params { ) inherits confdroid_ntp::params {
include confdroid_ntp::main::service include confdroid_ntp::main::service
# if $ay_manage_nagios == true { if $cy_manage_nagios == true {
# include confdroid_ntp::monitoring::target include confdroid_ntp::monitoring::target
# } }
} }

View File

@@ -6,4 +6,18 @@
class confdroid_ntp::monitoring::target ( class confdroid_ntp::monitoring::target (
) inherits confdroid_ntp::params { ) inherits confdroid_ntp::params {
if $cy_manage_nagios == true {
@@nagios_service { "check_chronyd_${fqdn}":
check_command => "check_nrpe!check_chronyd!${cy_procs_allowed}!chrony",
use => 'generic-service',
host_name => $fqdn,
notification_period => '24x7',
service_description => "${fqdn}_check_chronyd",
target => $cy_target_service,
owner => 'nagios',
group => 'nagios',
mode => '0640',
contacts => $cy_target_contacts,
}
}
} }

View File

@@ -18,6 +18,10 @@
# @param [String] cy_loginfo Log information to record. Valid values are # @param [String] cy_loginfo Log information to record. Valid values are
# 'measurements', 'statistics', and 'tracking'. # 'measurements', 'statistics', and 'tracking'.
# @param [Boolean] cy_use_lan_server Whether to use a local LAN server or external pool. # @param [Boolean] cy_use_lan_server Whether to use a local LAN server or external pool.
# @param [Boolean] cy_manage_nagios Whether to manage Nagios monitoring for the module.
# @param [String] cy_procs_allowed Number of allowed processes for the Nagios check.
# @param [String] cy_target_service Path to the Nagios service configuration file.
# @param [Array] cy_target_contacts List of Nagios contacts for notifications.
############################################################################### ###############################################################################
class confdroid_ntp::params ( class confdroid_ntp::params (
@@ -35,6 +39,12 @@ class confdroid_ntp::params (
String $cy_leapsectz = 'right/UTC', String $cy_leapsectz = 'right/UTC',
String $cy_loginfo = 'measurements statistics tracking', String $cy_loginfo = 'measurements statistics tracking',
# monitoring
Boolean $cy_manage_nagios = false,
String $cy_procs_allowed = '1',
String $cy_target_service = '/etc/nagios/conf.d/chronyd_service.cfg',
Array $cy_target_contacts = ['admin'],
) { ) {
# facts # facts
$fqdn = $facts['networking']['fqdn'] $fqdn = $facts['networking']['fqdn']