diff --git a/.github/docker/Dockerfile.packaging-plugins-alma8 b/.github/docker/Dockerfile.packaging-plugins-alma8 index 5e162edb8..19fcc1b24 100644 --- a/.github/docker/Dockerfile.packaging-plugins-alma8 +++ b/.github/docker/Dockerfile.packaging-plugins-alma8 @@ -2,9 +2,15 @@ ARG REGISTRY_URL FROM ${REGISTRY_URL}/almalinux:8 -RUN <> $GITHUB_OUTPUT - VERSION=`date '+%Y%m%d'` + if [[ "${{ inputs.version_file }}" == "" ]]; then + VERSION=$(date '+%Y%m%d') + else + VERSION=$(grep VERSION ${{ inputs.version_file }} | cut -d "'" -f 2) + fi echo "version=$(echo $VERSION)" >> $GITHUB_OUTPUT - RELEASE=`date '+%H%M%S'` + RELEASE=$(date '+%H%M%S') echo "release=$(echo $RELEASE)" >> $GITHUB_OUTPUT shell: bash diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 000000000..0e8a65477 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,139 @@ +on: + workflow_call: + inputs: + module_directory: + type: string + description: The module directory + required: true + nfpm_file_pattern: + type: string + description: The pattern of the nfpm configuration file(s) + required: true + distrib: + type: string + description: The distrib + required: true + package_extension: + type: string + description: The package extension (deb or rpm) + required: true + image_name: + type: string + description: The image name + required: true + version: + type: string + description: The package version + required: true + release: + type: string + description: The release number + required: true + cache_key: + type: string + description: The package files cache key + required: true + +jobs: + package: + runs-on: ubuntu-22.04 + container: + image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ inputs.image_name }} + credentials: + username: ${{ secrets.DOCKER_REGISTRY_ID }} + password: ${{ secrets.DOCKER_REGISTRY_PASSWD }} + + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Replace git sources by encoded files + if: "${{ inputs.encode_cache_key != '' }}" + run: | + rm -rf ${{ inputs.module_directory }} + tar zxf ${{ inputs.module_directory }}-${{ inputs.major_version }}.${{ inputs.minor_version }}.tar.gz + rm -f ${{ inputs.module_directory }}-${{ inputs.major_version }}.${{ inputs.minor_version }}.tar.gz + mv ${{ inputs.module_directory }}-${{ inputs.major_version }}.${{ inputs.minor_version }} ${{ inputs.module_directory }} + shell: bash + + - name: Restore static directory cache + if: "${{ inputs.frontend_static_directory != '' && inputs.frontend_static_cache_key != '' }}" + uses: actions/cache@v3 + with: + path: ${{ inputs.frontend_static_directory }} + key: ${{ inputs.frontend_static_cache_key }} + fail-on-cache-miss: true + + - name: Restore translation directory cache + if: "${{ inputs.translation_directory != '' && inputs.translation_cache_key != '' }}" + uses: actions/cache@v3 + with: + path: ${{ inputs.translation_directory }} + key: ${{ inputs.translation_cache_key }} + fail-on-cache-miss: true + + - name: Import gpg key + env: + RPM_GPG_SIGNING_KEY: ${{ secrets.RPM_GPG_SIGNING_KEY }} + run: echo -n "$RPM_GPG_SIGNING_KEY" > key.gpg + shell: bash + + - name: Build ${{ inputs.package_extension }} files + env: + RPM_GPG_SIGNING_KEY_ID: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }} + RPM_GPG_SIGNING_PASSPHRASE: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }} + run: | + export MAJOR_VERSION="${{ inputs.major_version }}" + export VERSION="${{ inputs.major_version }}.${{ inputs.minor_version }}" + export RELEASE="${{ inputs.release }}" + + if [ "${{ inputs.package_extension }}" = "rpm" ]; then + export DIST=".${{ inputs.distrib }}" + export APACHE_USER="apache" + export APACHE_GROUP="apache" + else + export DIST="" + export APACHE_USER="www-data" + export APACHE_GROUP="www-data" + fi + + MAJOR_LEFT=$( echo $MAJOR_VERSION | cut -d "." -f1 ) + MAJOR_RIGHT=$( echo $MAJOR_VERSION | cut -d "-" -f1 | cut -d "." -f2 ) + BUMP_MAJOR_RIGHT=$(( MAJOR_RIGHT_PART + 1 )) + if [ "$MAJOR_RIGHT" = "04" ]; then + BUMP_MAJOR_LEFT="$MAJOR_LEFT" + BUMP_MAJOR_RIGHT="10" + else + BUMP_MAJOR_LEFT=$(( $MAJOR_LEFT + 1 )) + BUMP_MAJOR_RIGHT="04" + fi + + export NEXT_MAJOR_VERSION="$BUMP_MAJOR_LEFT.$BUMP_MAJOR_RIGHT" + + export RPM_SIGNING_KEY_FILE="$(pwd)/key.gpg" + export RPM_SIGNING_KEY_ID="$RPM_GPG_SIGNING_KEY_ID" + export NFPM_RPM_PASSPHRASE="$RPM_GPG_SIGNING_PASSPHRASE" + + for FILE in ${{ inputs.nfpm_file_pattern }}; do + DIRNAME=$(dirname $FILE) + BASENAME=$(basename $FILE) + cd $DIRNAME + sed -i "s/@COMMIT_HASH@/${{ github.sha }}/g" $BASENAME + nfpm package --config $BASENAME --packager ${{ inputs.package_extension }} + cd - + mv $DIRNAME/*.${{ inputs.package_extension }} ./ + done + shell: bash + + - name: Upload package artifacts + uses: actions/upload-artifact@v3 + with: + name: packages-${{ inputs.package_extension }} + path: ./*.${{ inputs.package_extension }} + retention-days: 1 + + - name: Cache packages + uses: actions/cache@v3 + with: + path: ./*.${{ inputs.package_extension }} + key: ${{ inputs.cache_key }} diff --git a/connectors/vmware/packaging/centreon-plugin-virtualization-vmware-daemon.yaml b/connectors/vmware/packaging/centreon-plugin-virtualization-vmware-daemon.yaml new file mode 100644 index 000000000..21b027945 --- /dev/null +++ b/connectors/vmware/packaging/centreon-plugin-virtualization-vmware-daemon.yaml @@ -0,0 +1,93 @@ +name: "centreon-plugin-Virtualization-VMWare-daemon" +arch: "all" +platform: "linux" +version_schema: "none" +version: "${VERSION}" +release: "${RELEASE}${DIST}" +section: "default" +priority: "optional" +maintainer: "Centreon " +description: | + Centreon VMWare connector to interact from centreon plugins to vmware sdk. + Commit: @COMMIT_HASH@ +vendor: "Centreon" +homepage: "https://centreon.com" +license: "Apache-2.0" + +replaces: + - ces-plugins-Virtualization-VMWare-daemon + - centreon-plugin-Virtualisation-VMWare-daemon +conflicts: + - ces-plugins-Virtualization-VMWare-daemon + - centreon-plugin-Virtualisation-VMWare-daemon +provides: + - ces-plugins-Virtualization-VMWare-daemon + - centreon-plugin-Virtualisation-VMWare-daemon + +contents: + - src: "../src/centreon/vmware" + dst: "/usr/share/perl5/vendor_perl/centreon/vmware" + packager: rpm + - src: "../src/centreon/vmware" + dst: "/usr/share/perl5/centreon/vmware" + packager: deb + + - src: "../src/centreon/script/centreon_vmware.pm" + dst: "/usr/share/perl5/vendor_perl/centreon/script/centreon_vmware.pm" + packager: rpm + - src: "../src/centreon/script/centreon_vmware.pm" + dst: "/usr/share/perl5/centreon/script/centreon_vmware.pm" + packager: deb + + - src: "../src/centreon_vmware.pl" + dst: "/usr/bin/centreon_vmware.pl" + file_info: + mode: 0755 + + - src: "../redhat/centreon_vmware-systemd" + dst: "/etc/systemd/system/centreon_vmware.service" + file_info: + mode: 0755 + packager: rpm + - src: "../debian/centreon_vmware-systemd" + dst: "/lib/systemd/system/centreon_vmware.service" + file_info: + mode: 0755 + packager: deb + + - src: "../redhat/centreon_vmware-sysconfig" + dst: "/etc/sysconfig/centreon_vmware" + packager: rpm + - src: "../debian/centreon_vmware-default" + dst: "/etc/default/centreon_vmware" + packager: deb + + - src: "../config/centreon_vmware-conf.pm" + dst: "/etc/centreon/centreon_vmware.pm" + type: config|noreplace + +overrides: + rpm: + depends: + - perl-VMware-vSphere >= 5.1 + - perl(ZMQ::LibZMQ4) + - perl(ZMQ::Constants) + - perl(LWP::Protocol::https) + - perl(IO::Socket::INET6) + - perl(JSON::XS) + - perl-Net-Curl + deb: + depends: + - perl-vmware-vsphere + - zmq-libzmq4-perl + - libzmq-constants-perl + - liblwp-protocol-https-perl + - libio-socket-inet6-perl + - libjson-xs-perl + - libnet-curl-perl + - libtext-template-perl + +rpm: + signature: + key_file: ${RPM_SIGNING_KEY_FILE} + key_id: ${RPM_SIGNING_KEY_ID} diff --git a/connectors/vmware/packaging/debian/centreon_vmware-default b/connectors/vmware/packaging/debian/centreon_vmware-default index a5aca771a..e67053299 100644 --- a/connectors/vmware/packaging/debian/centreon_vmware-default +++ b/connectors/vmware/packaging/debian/centreon_vmware-default @@ -1,9 +1,2 @@ -# Configuration for /etc/init.d/centreon_vmware - -# If run centcore at startup default: YES -RUN_AT_STARTUP="YES" - -# Centreon user default: root -CENTREON_USER="root" - +# centreon_vmware command line options OPTIONS="--logfile=/var/log/centreon_vmware.log --severity=error" \ No newline at end of file