Merge branch 'jenkins-build-4' into 'master'
Auto-merge for build 4 See merge request puppet/confdroid_ssh!4
This commit is contained in:
129
Jenkinsfile
vendored
129
Jenkinsfile
vendored
@@ -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
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
- install required binaries
|
- install required binaries
|
||||||
- manage configuration based on parameters
|
- manage local custom configuration based on parameters, overriding the defaults
|
||||||
- manage service
|
- manage service
|
||||||
- (optional) manage firewall
|
- (optional) manage firewall
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ class confdroid_ssh::firewall::iptables (
|
|||||||
if $ssh_use_firewall {
|
if $ssh_use_firewall {
|
||||||
firewall { "${ssh_fw_order}${ssh_fw_port} allow SSH on port ${ssh_fw_port}":
|
firewall { "${ssh_fw_order}${ssh_fw_port} allow SSH on port ${ssh_fw_port}":
|
||||||
ensure => 'present',
|
ensure => 'present',
|
||||||
jump => 'accept',
|
|
||||||
proto => 'tcp',
|
proto => 'tcp',
|
||||||
|
source => $ssh_source_range,
|
||||||
dport => $ssh_fw_port,
|
dport => $ssh_fw_port,
|
||||||
|
jump => 'accept',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,4 +18,15 @@ class confdroid_ssh::main::dirs (
|
|||||||
seltype => etc_t,
|
seltype => etc_t,
|
||||||
seluser => system_u,
|
seluser => system_u,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file { $sshd_custom_path:
|
||||||
|
ensure => directory,
|
||||||
|
owner => $sshd_user,
|
||||||
|
group => $sshd_user,
|
||||||
|
mode => '0755',
|
||||||
|
selrange => s0,
|
||||||
|
selrole => object_r,
|
||||||
|
seltype => etc_t,
|
||||||
|
seluser => system_u,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ class confdroid_ssh::main::files (
|
|||||||
file { $sshd_config_path:
|
file { $sshd_config_path:
|
||||||
ensure => file,
|
ensure => file,
|
||||||
path => $sshd_config_path,
|
path => $sshd_config_path,
|
||||||
owner => 'root',
|
owner => $sshd_user,
|
||||||
group => 'root',
|
group => $sshd_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
selrange => s0,
|
selrange => s0,
|
||||||
selrole => object_r,
|
selrole => object_r,
|
||||||
@@ -19,4 +19,19 @@ class confdroid_ssh::main::files (
|
|||||||
seluser => system_u,
|
seluser => system_u,
|
||||||
content => template($sshd_config_erb),
|
content => template($sshd_config_erb),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if $ssh_manage_config {
|
||||||
|
file { $sshd_custom_conf:
|
||||||
|
ensure => file,
|
||||||
|
path => $sshd_custom_conf,
|
||||||
|
owner => $sshd_user,
|
||||||
|
group => $sshd_user,
|
||||||
|
mode => '0755',
|
||||||
|
selrange => s0,
|
||||||
|
selrole => object_r,
|
||||||
|
seltype => etc_t,
|
||||||
|
seluser => system_u,
|
||||||
|
content => template($sshd_custom_erb),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
# @param [Boolean] ssh_use_firewall whether to manage firewall settings
|
# @param [Boolean] ssh_use_firewall whether to manage firewall settings
|
||||||
# @param [String] ssh_fw_port port to use for SSHD and in fw
|
# @param [String] ssh_fw_port port to use for SSHD and in fw
|
||||||
# @param [String] ssh_fw_order order of firewall rule
|
# @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
|
||||||
##############################################################################
|
##############################################################################
|
||||||
class confdroid_ssh::params (
|
class confdroid_ssh::params (
|
||||||
|
|
||||||
@@ -17,6 +19,10 @@ class confdroid_ssh::params (
|
|||||||
Boolean $ssh_use_firewall = true,
|
Boolean $ssh_use_firewall = true,
|
||||||
String $ssh_fw_port = '22',
|
String $ssh_fw_port = '22',
|
||||||
String $ssh_fw_order = '50',
|
String $ssh_fw_order = '50',
|
||||||
|
String $ssh_source_range = '0.0.0.0/0',
|
||||||
|
|
||||||
|
# main configuration
|
||||||
|
Boolean $ssh_manage_config = true,
|
||||||
|
|
||||||
) {
|
) {
|
||||||
# default facts
|
# default facts
|
||||||
@@ -30,6 +36,9 @@ class confdroid_ssh::params (
|
|||||||
$ssh_etc_path = '/etc/ssh'
|
$ssh_etc_path = '/etc/ssh'
|
||||||
$sshd_service = 'sshd'
|
$sshd_service = 'sshd'
|
||||||
$sshd_config_path = "${ssh_etc_path}/sshd_config"
|
$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_config_erb = 'confdroid_ssh/ssh_config.erb'
|
||||||
|
|
||||||
# includes must be last
|
# includes must be last
|
||||||
|
|||||||
7
templates/ssh_custom_conf.erb
Normal file
7
templates/ssh_custom_conf.erb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
###############################################################################
|
||||||
|
##### DO NOT EDIT THIS FILE MANUALLY #
|
||||||
|
##### This file is managed by Puppet. Any changes to this file will be #
|
||||||
|
##### overwritten. The file is built via parameters, so any changes should #
|
||||||
|
##### be made in the Puppet manifest parameters. #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
Reference in New Issue
Block a user