diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index b3cb9f6..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,105 +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 - ''' - } - } - } - } -} \ No newline at end of file diff --git a/README.md b/README.md index f647666..f89e32b 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,11 @@ ## Features +- install required binaries +- manage configuration based on parameters +- manage service +- (optional) manage firewall + ## Support - Rocky 9 diff --git a/manifests/firewall/iptables.pp b/manifests/firewall/iptables.pp new file mode 100644 index 0000000..83571b5 --- /dev/null +++ b/manifests/firewall/iptables.pp @@ -0,0 +1,17 @@ +## confdroid_ssh::firewall::iptables.pp +# Module name: confdroid_ssh +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary Class manages firewall rules for SSH +############################################################################## +class confdroid_ssh::firewall::iptables ( + +) inherits confdroid_ssh::params { + if $ssh_use_firewall { + firewall { "${ssh_fw_order}${ssh_fw_port} allow SSH on port ${ssh_fw_port}": + ensure => 'present', + jump => 'accept', + proto => 'tcp', + dport => $ssh_fw_port, + } + } +} diff --git a/manifests/main/install.pp b/manifests/main/install.pp index b2ca70d..b17e11f 100644 --- a/manifests/main/install.pp +++ b/manifests/main/install.pp @@ -5,7 +5,7 @@ ############################################################################## class confdroid_ssh::main::install ( ) inherits confdroid_ssh::params { - package { $reqpackages: + package { $ssh_reqpackages: ensure => $pkg_ensure, } } diff --git a/manifests/main/service.pp b/manifests/main/service.pp index 639fdca..50c048f 100644 --- a/manifests/main/service.pp +++ b/manifests/main/service.pp @@ -6,6 +6,9 @@ class confdroid_ssh::main::service ( ) inherits confdroid_ssh::params { require confdroid_ssh::main::files + if $ssh_use_firewall { + require confdroid_ssh::firewall::iptables + } service { $sshd_service: ensure => running, diff --git a/manifests/params.pp b/manifests/params.pp index 520f6cb..2eb098a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -2,13 +2,21 @@ # Module name: confdroid_ssh # Author: 12ww1160 (12ww1160@confdroid.com) # @summary Class contains all class parameters for confdroid_ssh -# @param [Array] reqpackages packages to install +# @param [Array] ssh_reqpackages packages to install # @param [String] pkg_ensure version to install: 'present' or 'latest' +# @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_order order of firewall rule ############################################################################## class confdroid_ssh::params ( - Array $reqpackages = ['openssh','openssh-clients','openssh-server'], - String $pkg_ensure = 'present', + Array $ssh_reqpackages = ['openssh','openssh-clients','openssh-server'], + String $pkg_ensure = 'present', + + # firewall settings + Boolean $ssh_use_firewall = true, + String $ssh_fw_port = '22', + String $ssh_fw_order = '50', ) { # default facts