Compare commits
5 Commits
ea7e79203b
...
9feb38dd82
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9feb38dd82 | ||
|
|
99c69fba78 | ||
| bbc11e96e3 | |||
| 28879cbf65 | |||
|
|
2a707a4bab |
127
Jenkinsfile
vendored
127
Jenkinsfile
vendored
@@ -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
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -32,7 +32,7 @@ Time management in Linux is important. The underlying protocol is ntp, the servi
|
|||||||
|
|
||||||
This module differentiates between client- and server configuration. If the `FQDN` of the puppet client matches the value of `cy_server_fqdn`, it assumes this to be an ntp time server, else it will be a client.
|
This module differentiates between client- and server configuration. If the `FQDN` of the puppet client matches the value of `cy_server_fqdn`, it assumes this to be an ntp time server, else it will be a client.
|
||||||
|
|
||||||
If you have no local time server(s), leave the default for `cy_server_fqdn`.
|
If you have no local time server(s), leave `cy_use_lan_server` at `false` (default), else set it to `true`. This affects only client configurations.
|
||||||
|
|
||||||
The value for `cy_server_fqdn` is a string rather array, assuming either a single time server or a round-robin DNS entry for this, returning several values for the time server (not configured by this module).
|
The value for `cy_server_fqdn` is a string rather array, assuming either a single time server or a round-robin DNS entry for this, returning several values for the time server (not configured by this module).
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,12 @@
|
|||||||
|
|
||||||
<h2 id="label-Features">Features</h2>
|
<h2 id="label-Features">Features</h2>
|
||||||
|
|
||||||
|
<p>This module differentiates between client- and server configuration. If the <code>FQDN</code> of the puppet client matches the value of <code>cy_server_fqdn</code>, it assumes this to be an ntp time server, else it will be a client.</p>
|
||||||
|
|
||||||
|
<p>If you have no local time server(s), leave <code>cy_use_lan_server</code> at <code>false</code> (default), else set it to <code>true</code>. This affects only client configurations.</p>
|
||||||
|
|
||||||
|
<p>The value for <code>cy_server_fqdn</code> is a string rather array, assuming either a single time server or a round-robin DNS entry for this, returning several values for the time server (not configured by this module).</p>
|
||||||
|
|
||||||
<p>INSTALLATION</p>
|
<p>INSTALLATION</p>
|
||||||
<ul><li>
|
<ul><li>
|
||||||
<p>installs chrony binaries</p>
|
<p>installs chrony binaries</p>
|
||||||
@@ -110,7 +116,9 @@
|
|||||||
|
|
||||||
<p>CONFIGURATION</p>
|
<p>CONFIGURATION</p>
|
||||||
<ul><li>
|
<ul><li>
|
||||||
<p>manage directories and files including templates</p>
|
<p>manage directories including selinux contexts</p>
|
||||||
|
</li><li>
|
||||||
|
<p>and files and their templates including selinux contexts</p>
|
||||||
</li><li>
|
</li><li>
|
||||||
<p>manage service</p>
|
<p>manage service</p>
|
||||||
</li><li>
|
</li><li>
|
||||||
|
|||||||
@@ -103,6 +103,12 @@
|
|||||||
|
|
||||||
<h2 id="label-Features">Features</h2>
|
<h2 id="label-Features">Features</h2>
|
||||||
|
|
||||||
|
<p>This module differentiates between client- and server configuration. If the <code>FQDN</code> of the puppet client matches the value of <code>cy_server_fqdn</code>, it assumes this to be an ntp time server, else it will be a client.</p>
|
||||||
|
|
||||||
|
<p>If you have no local time server(s), leave <code>cy_use_lan_server</code> at <code>false</code> (default), else set it to <code>true</code>. This affects only client configurations.</p>
|
||||||
|
|
||||||
|
<p>The value for <code>cy_server_fqdn</code> is a string rather array, assuming either a single time server or a round-robin DNS entry for this, returning several values for the time server (not configured by this module).</p>
|
||||||
|
|
||||||
<p>INSTALLATION</p>
|
<p>INSTALLATION</p>
|
||||||
<ul><li>
|
<ul><li>
|
||||||
<p>installs chrony binaries</p>
|
<p>installs chrony binaries</p>
|
||||||
@@ -110,7 +116,9 @@
|
|||||||
|
|
||||||
<p>CONFIGURATION</p>
|
<p>CONFIGURATION</p>
|
||||||
<ul><li>
|
<ul><li>
|
||||||
<p>manage directories and files including templates</p>
|
<p>manage directories including selinux contexts</p>
|
||||||
|
</li><li>
|
||||||
|
<p>and files and their templates including selinux contexts</p>
|
||||||
</li><li>
|
</li><li>
|
||||||
<p>manage service</p>
|
<p>manage service</p>
|
||||||
</li><li>
|
</li><li>
|
||||||
|
|||||||
@@ -152,7 +152,7 @@
|
|||||||
<span class='type'>(<tt>String</tt>)</span>
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
<em class="default">(defaults to: <tt>'ntp.example.com'</tt>)</em>
|
<em class="default">(defaults to: <tt>'ntp.example.local'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
—
|
—
|
||||||
@@ -176,6 +176,114 @@
|
|||||||
—
|
—
|
||||||
<div class='inline'>
|
<div class='inline'>
|
||||||
<p>List of NTP servers to point to as time source</p>
|
<p>List of NTP servers to point to as time source</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cy_min_sources</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'3'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>Minimum number of selectable sources required to adjust the system clock. Primarily used for servers.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cy_client_allow</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'192.168.1.0/24'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>CIDR notation for allowed client networks</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cy_leapsec_mode</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'slew'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>Leap second handling mode. Valid values are ‘slew’ or ‘step’.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cy_leapsectz</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'right/UTC'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>Leap second timezone file to use.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cy_loginfo</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>'measurements statistics tracking'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>Log information to record. Valid values are ‘measurements’, ‘statistics’, and ‘tracking’.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>cy_use_lan_server</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>Boolean</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>false</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>Whether to use a local LAN server or external pool.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
@@ -191,15 +299,6 @@
|
|||||||
<pre class="lines">
|
<pre class="lines">
|
||||||
|
|
||||||
|
|
||||||
13
|
|
||||||
14
|
|
||||||
15
|
|
||||||
16
|
|
||||||
17
|
|
||||||
18
|
|
||||||
19
|
|
||||||
20
|
|
||||||
21
|
|
||||||
22
|
22
|
||||||
23
|
23
|
||||||
24
|
24
|
||||||
@@ -219,36 +318,57 @@
|
|||||||
38
|
38
|
||||||
39
|
39
|
||||||
40
|
40
|
||||||
41</pre>
|
41
|
||||||
|
42
|
||||||
|
43
|
||||||
|
44
|
||||||
|
45
|
||||||
|
46
|
||||||
|
47
|
||||||
|
48
|
||||||
|
49
|
||||||
|
50
|
||||||
|
51
|
||||||
|
52
|
||||||
|
53
|
||||||
|
54
|
||||||
|
55
|
||||||
|
56</pre>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 13</span>
|
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 22</span>
|
||||||
|
|
||||||
class confdroid_ntp::params (
|
class confdroid_ntp::params (
|
||||||
|
|
||||||
# installation
|
# installation
|
||||||
Array $cy_reqpackages = ['chrony'],
|
Array $cy_reqpackages = ['chrony'],
|
||||||
String $cy_pkg_ensure = 'present',
|
String $cy_pkg_ensure = 'present',
|
||||||
|
|
||||||
# configuration
|
# configuration
|
||||||
String $cy_server_fqdn = 'ntp.example.com',
|
Boolean $cy_use_lan_server = false,
|
||||||
Array $cy_conf_servers = ['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'],
|
String $cy_server_fqdn = 'ntp.example.local',
|
||||||
|
Array $cy_conf_servers = ['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'],
|
||||||
|
String $cy_min_sources = '3',
|
||||||
|
String $cy_client_allow = '192.168.1.0/24',
|
||||||
|
String $cy_leapsec_mode = 'slew',
|
||||||
|
String $cy_leapsectz = 'right/UTC',
|
||||||
|
String $cy_loginfo = 'measurements statistics tracking',
|
||||||
|
|
||||||
) {
|
) {
|
||||||
# facts
|
# facts
|
||||||
$fqdn = $facts['networking']['fqdn']
|
$fqdn = $facts['networking']['fqdn']
|
||||||
$domain = $facts['networking']['domain']
|
$domain = $facts['networking']['domain']
|
||||||
$os_name = $facts['os']['name']
|
$os_name = $facts['os']['name']
|
||||||
$os_release = $facts['os']['release']['major']
|
$os_release = $facts['os']['release']['major']
|
||||||
|
|
||||||
# dirs
|
# dirs
|
||||||
|
|
||||||
# files
|
# files
|
||||||
$cy_conf_file = '/etc/chrony.conf'
|
$cy_conf_file = '/etc/chrony.conf'
|
||||||
$cy_conf_erb = 'confdroid_ntp/chrony.conf.erb'
|
$cy_conf_erb = 'confdroid_ntp/chrony.conf.erb'
|
||||||
|
|
||||||
# service
|
# service
|
||||||
$cy_service = 'chronyd'
|
$cy_service = 'chronyd'
|
||||||
|
|
||||||
# includes must be last
|
# includes must be last
|
||||||
include confdroid_ntp::main::config
|
include confdroid_ntp::main::config
|
||||||
|
|||||||
@@ -17,37 +17,39 @@
|
|||||||
# @param [String] cy_leapsectz Leap second timezone file to use.
|
# @param [String] cy_leapsectz Leap second timezone file to use.
|
||||||
# @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.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
class confdroid_ntp::params (
|
class confdroid_ntp::params (
|
||||||
|
|
||||||
# installation
|
# installation
|
||||||
Array $cy_reqpackages = ['chrony'],
|
Array $cy_reqpackages = ['chrony'],
|
||||||
String $cy_pkg_ensure = 'present',
|
String $cy_pkg_ensure = 'present',
|
||||||
|
|
||||||
# configuration
|
# configuration
|
||||||
String $cy_server_fqdn = 'ntp.example.local',
|
Boolean $cy_use_lan_server = false,
|
||||||
Array $cy_conf_servers = ['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'],
|
String $cy_server_fqdn = 'ntp.example.local',
|
||||||
String $cy_min_sources = '3',
|
Array $cy_conf_servers = ['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'],
|
||||||
String $cy_client_allow = '192.168.1.0/24',
|
String $cy_min_sources = '3',
|
||||||
String $cy_leapsec_mode = 'slew',
|
String $cy_client_allow = '192.168.1.0/24',
|
||||||
String $cy_leapsectz = 'right/UTC',
|
String $cy_leapsec_mode = 'slew',
|
||||||
String $cy_loginfo = 'measurements statistics tracking',
|
String $cy_leapsectz = 'right/UTC',
|
||||||
|
String $cy_loginfo = 'measurements statistics tracking',
|
||||||
|
|
||||||
) {
|
) {
|
||||||
# facts
|
# facts
|
||||||
$fqdn = $facts['networking']['fqdn']
|
$fqdn = $facts['networking']['fqdn']
|
||||||
$domain = $facts['networking']['domain']
|
$domain = $facts['networking']['domain']
|
||||||
$os_name = $facts['os']['name']
|
$os_name = $facts['os']['name']
|
||||||
$os_release = $facts['os']['release']['major']
|
$os_release = $facts['os']['release']['major']
|
||||||
|
|
||||||
# dirs
|
# dirs
|
||||||
|
|
||||||
# files
|
# files
|
||||||
$cy_conf_file = '/etc/chrony.conf'
|
$cy_conf_file = '/etc/chrony.conf'
|
||||||
$cy_conf_erb = 'confdroid_ntp/chrony.conf.erb'
|
$cy_conf_erb = 'confdroid_ntp/chrony.conf.erb'
|
||||||
|
|
||||||
# service
|
# service
|
||||||
$cy_service = 'chronyd'
|
$cy_service = 'chronyd'
|
||||||
|
|
||||||
# includes must be last
|
# includes must be last
|
||||||
include confdroid_ntp::main::config
|
include confdroid_ntp::main::config
|
||||||
|
|||||||
@@ -63,7 +63,13 @@ log <%= @cy_loginfo %>
|
|||||||
|
|
||||||
<% if @fqdn != @cy_server_fqdn -%>
|
<% if @fqdn != @cy_server_fqdn -%>
|
||||||
# This is a time client configuration file
|
# This is a time client configuration file
|
||||||
|
<% if @cy_use_lan_server -%>
|
||||||
server <%= @cy_server_fqdn %> iburst
|
server <%= @cy_server_fqdn %> iburst
|
||||||
|
<% else -%>
|
||||||
|
# Use public servers from the pool.ntp.org project.
|
||||||
|
<% @cy_conf_servers.each do |this_server| -%>
|
||||||
|
server <%= this_server %> iburst
|
||||||
|
<% end end -%>
|
||||||
|
|
||||||
# Use NTP servers from DHCP.
|
# Use NTP servers from DHCP.
|
||||||
sourcedir /run/chrony-dhcp
|
sourcedir /run/chrony-dhcp
|
||||||
@@ -79,7 +85,7 @@ makestep 1.0 3
|
|||||||
rtcsync
|
rtcsync
|
||||||
|
|
||||||
# Enable hardware timestamping on all interfaces that support it.
|
# Enable hardware timestamping on all interfaces that support it.
|
||||||
hwtimestamp *
|
# hwtimestamp *
|
||||||
|
|
||||||
# Increase the minimum number of selectable sources required to adjust
|
# Increase the minimum number of selectable sources required to adjust
|
||||||
# the system clock. Primarily for servers.
|
# the system clock. Primarily for servers.
|
||||||
|
|||||||
Reference in New Issue
Block a user