From bf13aefe0ea6c3766638ce535f49cea6919b7e88 Mon Sep 17 00:00:00 2001 From: PiR-B Date: Fri, 21 Jun 2024 10:10:53 +0200 Subject: [PATCH] Handle Nexus versions >= 3.67.0-03 (#62) * Handle Nexus versions >= 3.67.0-03 --------- Co-authored-by: Pierre Baret --- manifests/init.pp | 25 ++++++++++++++++--------- manifests/package.pp | 9 ++++++++- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 353bc7e..bc450ee 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,14 +3,10 @@ # # @see https://help.sonatype.com/repomanager3/product-information/download/download-archives---repository-manager-3 # -# @param version -# The version to download, install and manage. # @param download_folder # Destination folder of the downloaded archive. # @param download_site # Download uri which will be appended with filename of the archive to download. -# @param download_proxy -# Proxyserver address which will be used to download the archive file. # @param install_root # The root filesystem path where the downloaded archive will be extracted to. # @param work_dir @@ -38,10 +34,16 @@ # @param package_type # Select 'src' for Source download & install. 'pkg' will fetch te specified package and version # from repos you must provide. -# @param package_name -# The name of the package to install. Default 'nexus' # @param package_ensure # The version to install. See https://puppet.com/docs/puppet/7/types/package.html#package-attribute-ensure +# @param download_proxy +# Proxyserver address which will be used to download the archive file. +# @param version +# The version to download, install and manage. +# @param java_runtime +# The Java runtime to be utilized. Relevant only for Nexus versions >= 3.67.0-03. +# @param package_name +# The name of the package to install. Default 'nexus' # # @example # class{ 'nexus': @@ -49,10 +51,8 @@ # } # class nexus ( - Optional[Pattern[/3.\d+.\d+-\d+/]] $version, Stdlib::Absolutepath $download_folder, Stdlib::HTTPUrl $download_site, - Optional[Stdlib::HTTPUrl] $download_proxy, Stdlib::Absolutepath $install_root, Stdlib::Absolutepath $work_dir, String[1] $user, @@ -66,11 +66,18 @@ Boolean $purge_installations, Boolean $purge_default_repositories, Enum['src', 'pkg'] $package_type, - Optional[String] $package_name, String $package_ensure, + Optional[Stdlib::HTTPUrl] $download_proxy = undef, + Optional[Pattern[/3.\d+.\d+-\d+/]] $version = undef, + Optional[Enum['java8', 'java11']] $java_runtime = undef, + Optional[String] $package_name = undef, ) { include stdlib + if ($version and versioncmp($version, '3.67.0-03') >= 0 and ! $java_runtime) { + fail('You need to define the $java_runtime parameter.') + } + contain nexus::user contain nexus::package diff --git a/manifests/package.pp b/manifests/package.pp index 544da3e..e5d45b3 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -11,7 +11,14 @@ if !$nexus::version { fail('nexus::version must be set when using package_type => src') } - $nexus_archive = "nexus-${nexus::version}-unix.tar.gz" + + if $nexus::java_runtime { + # Relevant only for Nexus versions >= 3.67.0-03 + $nexus_archive = "nexus-${nexus::version}-${nexus::java_runtime}-unix.tar.gz" + } else { + $nexus_archive = "nexus-${nexus::version}-unix.tar.gz" + } + $download_url = "${nexus::download_site}/${nexus_archive}" $dl_file = "${nexus::download_folder}/${nexus_archive}" $install_dir = "${nexus::install_root}/nexus-${nexus::version}"