Compare commits

...

6 Commits

Author SHA1 Message Date
Jenkins
f432c7b450 Merge branch 'jenkins-build-6' into 'master'
Auto-merge for build 6

See merge request puppet/confdroid_ssh!6
2026-04-05 16:12:17 +02:00
Jenkins Server
c504d32e8e Merge remote-tracking branch 'origin/master' into jenkins-build-6 2026-04-05 15:58:57 +02:00
ff0bacd593 OP#561 add config params 2026-04-05 15:58:39 +02:00
63dbe688d3 OP#561 add semanage 2026-04-05 15:55:33 +02:00
cb50502233 OP#561 add notification 2026-04-05 15:52:15 +02:00
Jenkins
36730c7841 Merge branch 'jenkins-build-5' into 'master'
Auto-merge for build 5

See merge request puppet/confdroid_ssh!5
2026-04-05 13:47:33 +00:00
8 changed files with 33 additions and 138 deletions

129
Jenkinsfile vendored
View File

@@ -1,129 +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_ssh \
-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 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
'''
}
}
}
stage('Mirror to Gitea') {
steps {
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_ssh.git
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
push master --mirror
'''
}
}
}
}
}
}

View File

@@ -26,6 +26,7 @@
- install required binaries
- manage local custom configuration based on parameters, overriding the defaults
- manage selinux rules
- manage service
- (optional) manage firewall

View File

@@ -18,6 +18,7 @@ class confdroid_ssh::main::files (
seltype => etc_t,
seluser => system_u,
content => template($sshd_config_erb),
notify => Service[$sshd_service],
}
if $ssh_manage_config {
@@ -32,6 +33,7 @@ class confdroid_ssh::main::files (
seltype => etc_t,
seluser => system_u,
content => template($sshd_custom_erb),
notify => Service[$sshd_service],
}
}
}

View File

@@ -6,6 +6,7 @@
class confdroid_ssh::main::service (
) inherits confdroid_ssh::params {
require confdroid_ssh::main::files
require confdroid_ssh::selinux::semanage
if $ssh_use_firewall {
require confdroid_ssh::firewall::iptables
}

View File

@@ -9,6 +9,8 @@
# @param [String] ssh_fw_order order of firewall rule
# @param [String] ssh_source_range source range for firewall rule
# @param [Boolean] ssh_manage_config whether to manage the configuration
# @param [String] ssh_address_family AddressFamily setting for sshd_config
# @param [String] ssh_listen_address ListenAddress setting for sshd_config
##############################################################################
class confdroid_ssh::params (
@@ -23,6 +25,8 @@ class confdroid_ssh::params (
# main configuration
Boolean $ssh_manage_config = true,
String $ssh_address_family = 'any',
String $ssh_listen_address = '0.0.0.0',
) {
# default facts
@@ -38,8 +42,8 @@ class confdroid_ssh::params (
$sshd_config_path = "${ssh_etc_path}/sshd_config"
$sshd_custom_path = "${ssh_etc_path}/sshd_config.d"
$sshd_custom_conf = "${sshd_custom_path}/10-custom.conf"
$sshd_custom_erb = 'confdroid_ssh/ssh_custom_conf.erb'
$sshd_config_erb = 'confdroid_ssh/ssh_config.erb'
$sshd_custom_erb = 'confdroid_ssh/sshd_custom_conf.erb'
$sshd_config_erb = 'confdroid_ssh/sshd_config.erb'
# includes must be last
include confdroid_ssh::main::config

View File

@@ -0,0 +1,13 @@
## confdroid_ssh::selinux::semanage.pp
# Module name: confdroid_ssh
# Author: 12ww1160 (12ww1160@confdroid.com)
# @summary Class manages SELinux semanage settings
##############################################################################
class confdroid_ssh::selinux::semanage (
) inherits confdroid_ssh::params {
exec { 'semanage_port_ssh':
command => "semanage port -a -t ssh_port_t -p tcp ${ssh_fw_port}",
unless => "semanage port -l | grep '^ssh_port_t' | grep 'tcp' | grep '${ssh_fw_port}'",
path => ['/usr/bin', '/usr/sbin'],
}
}

View File

@@ -5,3 +5,6 @@
##### be made in the Puppet manifest parameters. #
###############################################################################
Port <%= @ssh_fw_port %>
AddressFamily <%= @ssh_address_family %>
ListenAddress <%= @ssh_listen_address %>