feat(ci): add workflow to package centreon-nrpe3 (#4569)

Refs: MON-19408
This commit is contained in:
Kevin Duret 2023-07-24 10:46:06 +02:00 committed by GitHub
parent 92693dc6ae
commit 8719c1edd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 419 additions and 2 deletions

View File

@ -10,7 +10,7 @@ baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo
dnf -y install git gettext rpm-build dos2unix python3 epel-release nfpm jq zstd
dnf -y install gcc git gettext rpm-build dos2unix python3 epel-release nfpm openssl-devel jq zstd
dnf -y install perl-App-cpanminus perl-JSON
cpanm App::FatPacker
cpanm File::Copy::Recursive

View File

@ -10,7 +10,7 @@ baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo
dnf -y install git gettext rpm-build dos2unix python3 epel-release nfpm jq zstd
dnf -y install gcc git gettext rpm-build dos2unix python3 epel-release nfpm openssl-devel jq zstd
dnf -y install perl-App-cpanminus perl-JSON
cpanm App::FatPacker
cpanm File::Copy::Recursive

View File

@ -25,6 +25,7 @@ apt-get install -y \
dh-make \
aptitude \
ca-certificates \
libssh-dev \
lintian \
pbuilder \
quilt \
@ -33,6 +34,7 @@ apt-get install -y \
devscripts \
fakeroot \
curl \
gcc \
git \
python3 \
libjson-perl \

View File

@ -54,6 +54,8 @@ jobs:
if [[ "${{ inputs.version_file }}" == "" ]]; then
VERSION=$(date '+%Y%m%d')
elif [[ "${{ inputs.version_file }}" == */*.yaml ]]; then
VERSION=$(grep 'version: ' ${{ inputs.version_file }} | cut -d' ' -f2 | tr -d '"')
else
VERSION=$(grep VERSION ${{ inputs.version_file }} | cut -d "'" -f 2)
fi

153
.github/workflows/nrpe.yml vendored Normal file
View File

@ -0,0 +1,153 @@
name: nrpe
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- 'nrpe/packaging/**'
push:
branches:
- develop
- master
paths:
- 'nrpe/packaging/**'
tags:
- centreon-nrpe-*
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: nrpe/packaging/centreon-nrpe3-daemon.yaml
package:
needs: [get-environment]
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el8
- package_extension: rpm
image: packaging-plugins-alma9
distrib: el9
- package_extension: deb
image: packaging-plugins-bullseye
distrib: bullseye
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
name: package ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download nrpe sources
run: |
curl -Lo - "https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-${{ needs.get-environment.outputs.version }}/nrpe-${{ needs.get-environment.outputs.version }}.tar.gz" | tar zxpf -
mv nrpe-${{ needs.get-environment.outputs.version }} nrpe-src
shell: bash
- name: Compile sources
run: |
cd nrpe-src
patch -p1 < ../nrpe/packaging/files/nrpe3_add_centreon_cmd.patch
if [ "${{ matrix.package_extension }}" = "deb" ]; then
NAGIOS_PLUGINS_PATH="/usr/lib/nagios/plugins"
else
NAGIOS_PLUGINS_PATH="/usr/lib64/nagios/plugins"
fi
CXXFLAGS="-Wall -Wextra" ./configure \
--libexecdir="$NAGIOS_PLUGINS_PATH" \
--localstatedir="/var/log/nrpe" \
--sysconfdir="/etc/nrpe" \
--enable-command-args \
--with-nrpe-user="centreon-engine" \
--with-nrpe-group="centreon-engine" \
--with-nrpe-port="5666" \
--with-nagios-user="centreon-engine" \
--with-nagios-group="centreon-engine"
make all
shell: bash
- name: Generate debug files
run: |
cd nrpe-src/src
for file in "nrpe" "check_nrpe"; do
objcopy --only-keep-debug $file $file.debug
objcopy --strip-debug $file
objcopy --add-gnu-debuglink $file.debug $file
done
shell: bash
- name: Package
uses: ./.github/actions/package
with:
nfpm_file_pattern: "nrpe/packaging/*.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
commit_hash: ${{ github.sha }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
rpm_gpg_key: ${{ secrets.RPM_GPG_SIGNING_KEY }}
rpm_gpg_signing_key_id: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }}
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
deliver-rpm:
needs: [get-environment, package]
if: ${{ contains(fromJson('["stable", "testing", "unstable"]'), needs.get-environment.outputs.stability) }}
runs-on: [self-hosted, common]
strategy:
matrix:
distrib: [el8, el9]
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Delivery
uses: ./.github/actions/rpm-delivery
with:
module_name: nrpe
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
deliver-deb:
needs: [get-environment ,package]
if: ${{ contains(fromJson('["stable", "testing", "unstable"]'), needs.get-environment.outputs.stability) }}
runs-on: [self-hosted, common]
strategy:
matrix:
distrib: [bullseye]
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Delivery
uses: ./.github/actions/deb-delivery
with:
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}

View File

@ -0,0 +1,92 @@
name: "centreon-nrpe3-daemon"
arch: "amd64"
platform: "linux"
version_schema: "none"
version: "4.1.0"
release: "${RELEASE}${DIST}"
section: "default"
priority: "optional"
maintainer: "Centreon <contact@centreon.com>"
description: |
The centreon-nrpe packages contains the Nagios Remote Plug-ins Executor.
Daemon which can execute predefined commands on the remote host.
Commit: @COMMIT_HASH@
vendor: "Centreon"
homepage: "https://centreon.com"
license: "GPLv2+"
contents:
- src: "../../nrpe-src/src/nrpe"
dst: "/usr/sbin/centreon-nrpe3"
- src: "../../nrpe-src/sample-config/nrpe.cfg"
dst: "/etc/nrpe/centreon-nrpe3.cfg"
type: config|noreplace
file_info:
mode: 0644
- src: "files/nrpe3.sysconfig"
dst: "/etc/sysconfig/centreon-nrpe3"
packager: rpm
file_info:
mode: 0644
- src: "files/nrpe3.sysconfig"
dst: "/etc/default/centreon-nrpe3"
packager: deb
file_info:
mode: 0644
- src: "files/nrpe3.service.rpm"
dst: "/lib/systemd/system/centreon-nrpe3.service"
packager: rpm
file_info:
mode: 0644
- src: "files/nrpe3.service.deb"
dst: "/lib/systemd/system/centreon-nrpe3.service"
packager: deb
file_info:
mode: 0644
- dst: "/var/log/nrpe"
type: dir
file_info:
mode: 0755
owner: centreon-engine
group: centreon-engine
- dst: "/var/log/nrpe/centplugins"
type: dir
file_info:
mode: 0755
owner: centreon-engine
group: centreon-engine
scripts:
preinstall: ./scripts/centreon-nrpe3-daemon-preinstall.sh
postinstall: ./scripts/centreon-nrpe3-daemon-postinstall.sh
preremove: ./scripts/centreon-nrpe3-daemon-preremove.sh
overrides:
rpm:
replaces:
- centreon-nrpe3-daemon-debuginfo
- centreon-nrpe3-daemon-debugsource
conflicts:
- centreon-nrpe3-daemon-debuginfo
- centreon-nrpe3-daemon-debugsource
provides:
- centreon-nrpe3-daemon-debuginfo
- centreon-nrpe3-daemon-debugsource
deb:
replaces:
- centreon-nrpe3-daemon-dbgsym
conflicts:
- centreon-nrpe3-daemon-dbgsym
provides:
- centreon-nrpe3-daemon-dbgsym
rpm:
summary: Nagios Remote Plugins Execution daemon
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
key_id: ${RPM_SIGNING_KEY_ID}

View File

@ -0,0 +1,53 @@
name: "centreon-nrpe3-plugin"
arch: "amd64"
platform: "linux"
version_schema: "none"
version: "4.1.0"
release: "${RELEASE}${DIST}"
section: "default"
priority: "optional"
maintainer: "Centreon <contact@centreon.com>"
description: |
Plug-in for Centreon monitoring system.
The centreon-nrpe packages contains the Nagios Remote Plug-ins Executor
Commit: @COMMIT_HASH@
vendor: "Centreon"
homepage: "https://centreon.com"
license: "GPLv2+"
contents:
- src: "../../nrpe-src/src/check_nrpe"
dst: "/usr/lib64/nagios/plugins/check_centreon_nrpe3"
packager: rpm
file_info:
mode: 0755
- src: "../../nrpe-src/src/check_nrpe"
dst: "/usr/lib/nagios/plugins/check_centreon_nrpe3"
packager: deb
file_info:
mode: 0755
overrides:
rpm:
replaces:
- centreon-nrpe3-plugin-debuginfo
- centreon-nrpe3-plugin-debugsource
conflicts:
- centreon-nrpe3-plugin-debuginfo
- centreon-nrpe3-plugin-debugsource
provides:
- centreon-nrpe3-plugin-debuginfo
- centreon-nrpe3-plugin-debugsource
deb:
replaces:
- centreon-nrpe3-plugin-dbgsym
conflicts:
- centreon-nrpe3-plugin-dbgsym
provides:
- centreon-nrpe3-plugin-dbgsym
rpm:
summary: Nagios plugin for NRPE
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
key_id: ${RPM_SIGNING_KEY_ID}

View File

@ -0,0 +1,23 @@
[Unit]
Description=Nagios Remote Program Executor
Documentation=http://www.nagios.org/documentation
After=var-run.mount nss-lookup.target network.target local-fs.target time-sync.target
Before=getty@tty1.service plymouth-quit.service xdm.service
Conflicts=nrpe.socket
Requires=network.target
[Service]
Type=forking
User=centreon-engine
Group=centreon-engine
EnvironmentFile=/etc/default/centreon-nrpe3
ExecStart=/usr/sbin/centreon-nrpe3 -c /etc/nrpe/centreon-nrpe3.cfg -d $NRPE_OPT
Restart=on-abort
PIDFile=/var/log/nrpe/nrpe3.pid
ExecStopPost=/bin/rm -f /var/log/nrpe/nrpe3.pid
TimeoutStopSec=60
PrivateTmp=false
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,23 @@
[Unit]
Description=Nagios Remote Program Executor
Documentation=http://www.nagios.org/documentation
After=var-run.mount nss-lookup.target network.target local-fs.target time-sync.target
Before=getty@tty1.service plymouth-quit.service xdm.service
Conflicts=nrpe.socket
Requires=network.target
[Service]
Type=forking
User=centreon-engine
Group=centreon-engine
EnvironmentFile=/etc/sysconfig/centreon-nrpe3
ExecStart=/usr/sbin/centreon-nrpe3 -c /etc/nrpe/centreon-nrpe3.cfg -d $NRPE_OPT
Restart=on-abort
PIDFile=/var/log/nrpe/nrpe3.pid
ExecStopPost=/bin/rm -f /var/log/nrpe/nrpe3.pid
TimeoutStopSec=60
PrivateTmp=false
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,2 @@
# specify additional command line arguments for nrpe
NRPE_OPT=""

View File

@ -0,0 +1,29 @@
--- a/sample-config/nrpe.cfg.in 2018-09-14 13:40:08.496324915 +0200
+++ b/sample-config/nrpe.cfg.in 2018-09-14 13:47:57.624296953 +0200
@@ -40,7 +40,7 @@
# number. The file is only written if the NRPE daemon is started by the root
# user and is running in standalone mode.
-pid_file=@piddir@/nrpe.pid
+pid_file=@piddir@/nrpe3.pid
@@ -119,7 +119,7 @@
#
# Values: 0=do not allow arguments, 1=allow command arguments
-dont_blame_nrpe=0
+dont_blame_nrpe=1
@@ -300,7 +300,7 @@
command[check_hda1]=@pluginsdir@/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=@pluginsdir@/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=@pluginsdir@/check_procs -w 150 -c 200
-
+command[check_centreon_plugins]=/usr/lib/centreon/plugins/centreon_linux_local.pl --plugin=$ARG1$ --mode=$ARG2$ $ARG3$
# The following examples allow user-supplied arguments and can
# only be used if the NRPE daemon was compiled with support for

View File

@ -0,0 +1,31 @@
#!/bin/sh
startNrpeDaemon() {
systemctl daemon-reload ||:
systemctl unmask centreon-nrpe3.service ||:
systemctl preset centreon-nrpe3.service ||:
systemctl enable centreon-nrpe3.service ||:
systemctl restart centreon-nrpe3.service ||:
}
action="$1"
if [ "$1" = "configure" ] && [ -z "$2" ]; then
# Alpine linux does not pass args, and deb passes $1=configure
action="install"
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
# deb passes $1=configure $2=<current version>
action="upgrade"
fi
case "$action" in
"1" | "install")
startNrpeDaemon
;;
"2" | "upgrade")
startNrpeDaemon
;;
*)
# $1 == version being installed
startNrpeDaemon
;;
esac

View File

@ -0,0 +1,4 @@
#!/bin/sh
getent group centreon-engine > /dev/null 2>&1 || groupadd -r centreon-engine
getent passwd centreon-engine > /dev/null 2>&1 || useradd -g centreon-engine -m -d /var/lib/centreon-engine -r centreon-engine > /dev/null 2>&1 ||:

View File

@ -0,0 +1,3 @@
#!/bin/sh
systemctl stop centreon-nrpe3.service ||: