From a9e520b826a8c51d902cbc16279503023d5d66ae Mon Sep 17 00:00:00 2001 From: Frank Wall Date: Tue, 13 Aug 2024 13:55:44 +0200 Subject: [PATCH] move default values to module data (Hiera) --- REFERENCE.md | 83 ++++++++++++-------------------------- data/Debian-family.yaml | 6 +++ data/RedHat-family.yaml | 4 ++ data/common.yaml | 22 ++++++++++- hiera.yaml | 32 +++++++++------ manifests/init.pp | 88 +++++++++++++++++++++-------------------- 6 files changed, 123 insertions(+), 112 deletions(-) create mode 100644 data/Debian-family.yaml create mode 100644 data/RedHat-family.yaml diff --git a/REFERENCE.md b/REFERENCE.md index ddd4d79..f8e7b03 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -69,6 +69,7 @@ The following parameters are available in the `artifactory` class: * [`pool_max_active`](#-artifactory--pool_max_active) * [`pool_max_idle`](#-artifactory--pool_max_idle) * [`root_password`](#-artifactory--root_password) +* [`service_name`](#-artifactory--service_name) * [`symlink_name`](#-artifactory--symlink_name) * [`use_temp_db_secrets`](#-artifactory--use_temp_db_secrets) * [`yum_baseurl`](#-artifactory--yum_baseurl) @@ -77,43 +78,43 @@ The following parameters are available in the `artifactory` class: ##### `apt_baseurl` -Data type: `String` +Data type: `Optional[String]` Sets the URL of the APT repository. -Default value: `'https://releases.jfrog.io/artifactory/artifactory-debs'` +Default value: `undef` ##### `apt_baseurl_pro` -Data type: `String` +Data type: `Optional[String]` Sets the URL of the APT repository (Pro edition). -Default value: `'https://releases.jfrog.io/artifactory/artifactory-pro-debs'` +Default value: `undef` ##### `apt_key_id` -Data type: `String` +Data type: `Optional[String]` Sets the ID of the APT repository key. -Default value: `'A3D085F542F740BBD7E3A2846B219DCCD7639232'` +Default value: `undef` ##### `apt_key_source` -Data type: `String` +Data type: `Optional[String]` Sets the URL of the APT repository. -Default value: `'https://releases.jfrog.io/artifactory/api/gpg/key/public'` +Default value: `undef` ##### `apt_repos` -Data type: `String` +Data type: `Optional[String]` Sets the names of the APT repositories to enable. -Default value: `'main'` +Default value: `undef` ##### `archive_data_dir` @@ -121,24 +122,18 @@ Data type: `Stdlib::Absolutepath` The Artifactory data directory that should be used for archive installations. -Default value: `'/opt/artifactory-data'` - ##### `archive_install_dir` Data type: `Stdlib::Absolutepath` The Artifactory app directory that should be used for archive installations. -Default value: `'/opt'` - ##### `artifactory_home` Data type: `String` Specifies the main directory. -Default value: `'/var/opt/jfrog/artifactory'` - ##### `binary_provider_base_data_dir` Data type: `Optional[String]` @@ -194,28 +189,22 @@ Default value: `undef` ##### `config_group` -Data type: `Optional[String]` +Data type: `String` Specifies the group owner of the configuration files. -Default value: `'artifactory'` - ##### `config_owner` -Data type: `Optional[String]` +Data type: `String` Specifies the owner of the configuration files. -Default value: `'artifactory'` - ##### `db_automate` -Data type: `Optional[Boolean]` +Data type: `Boolean` Set to 'true' to let Puppet create a database (instance). Only supports MySQL. -Default value: `false` - ##### `db_password` Data type: `Optional[String]` @@ -254,48 +243,36 @@ Data type: `String` The filename of the archive distribution. -Default value: `'jfrog-artifactory-%s-%s-linux.tar.gz'` - ##### `download_url_oss` Data type: `String` The download URL for the open-source edition. -Default value: `'https://releases.jfrog.io/artifactory/bintray-artifactory/org/artifactory/oss/jfrog-artifactory-oss/%s/%s'` - ##### `download_url_pro` Data type: `String` The download URL for the pro edition. -Default value: `'https://releases.jfrog.io/artifactory/artifactory-pro/org/artifactory/pro/jfrog-artifactory-pro/%s/%s'` - ##### `edition` Data type: `Enum['oss', 'pro', 'enterprise']` Specifies the Artifactory edition/license. -Default value: `'oss'` - ##### `install_method` Data type: `String` Whether to use a package or an archive to install artifactory. -Default value: `'package'` - ##### `install_service_script` Data type: `String` Path to the installation script of the archive distribution. -Default value: `'app/bin/installService.sh'` - ##### `jdbc_driver_url` Data type: `Optional[String]` @@ -318,8 +295,6 @@ Data type: `Boolean` Whether to setup required repos or disable repo management. -Default value: `true` - ##### `master_key` Data type: `Optional[String]` @@ -337,24 +312,18 @@ Data type: `String` Sets the package name to install. -Default value: `'jfrog-artifactory-oss'` - ##### `package_name_pro` Data type: `String` Sets the package name to install (Pro edition). -Default value: `'jfrog-artifactory-pro'` - ##### `package_version` Data type: `String` Specifies the package version. -Default value: `'present'` - ##### `pool_max_active` Data type: `Optional[Integer]` @@ -373,11 +342,15 @@ Default value: `undef` ##### `root_password` -Data type: `Optional[String]` +Data type: `String` Sets the root password for Puppet managed mysql database instance. -Default value: `'password'` +##### `service_name` + +Data type: `String` + +Specifies the name of the Artifactory system service. ##### `symlink_name` @@ -386,8 +359,6 @@ Data type: `String` Controls the name of a version-independent symlink for the archive installation. It will always point to the release specified by `$package_version`. -Default value: `'artifactory'` - ##### `use_temp_db_secrets` Data type: `Boolean` @@ -397,29 +368,27 @@ Set to `false` to persist the file in `$artifactory_home/etc/db.properties`, which will allow to add database and storage options without Puppet touching it. -Default value: `true` - ##### `yum_baseurl` -Data type: `String` +Data type: `Optional[String]` Sets the URL of the yum repository. -Default value: `'https://jfrog.bintray.com/artifactory-rpms'` +Default value: `undef` ##### `yum_baseurl_pro` -Data type: `String` +Data type: `Optional[String]` Sets the URL of the yum repository (Pro edition). -Default value: `'https://jfrog.bintray.com/artifactory-pro-rpms'` +Default value: `undef` ##### `yum_name` -Data type: `String` +Data type: `Optional[String]` Sets the name of the yum repository. -Default value: `'bintray-jfrog-artifactory-rpms'` +Default value: `undef` diff --git a/data/Debian-family.yaml b/data/Debian-family.yaml new file mode 100644 index 0000000..76bcbc1 --- /dev/null +++ b/data/Debian-family.yaml @@ -0,0 +1,6 @@ +--- +artifactory::apt_baseurl: 'https://releases.jfrog.io/artifactory/artifactory-debs' +artifactory::apt_baseurl_pro: 'https://releases.jfrog.io/artifactory/artifactory-pro-debs' +artifactory::apt_key_id: 'A3D085F542F740BBD7E3A2846B219DCCD7639232' +artifactory::apt_key_source: 'https://releases.jfrog.io/artifactory/api/gpg/key/public' +artifactory::apt_repos: 'main' diff --git a/data/RedHat-family.yaml b/data/RedHat-family.yaml new file mode 100644 index 0000000..d24dbfb --- /dev/null +++ b/data/RedHat-family.yaml @@ -0,0 +1,4 @@ +--- +artifactory::yum_baseurl: 'https://jfrog.bintray.com/artifactory-rpms' +artifactory::yum_baseurl_pro: 'https://jfrog.bintray.com/artifactory-pro-rpms' +artifactory::yum_name: 'bintray-jfrog-artifactory-rpms' diff --git a/data/common.yaml b/data/common.yaml index 2fbf0ff..07715e4 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -1 +1,21 @@ ---- {} +--- +artifactory::archive_data_dir: '/opt/artifactory-data' +artifactory::archive_install_dir: '/opt' +artifactory::artifactory_home: '/var/opt/jfrog/artifactory' +artifactory::config_group: 'artifactory' +artifactory::config_owner: 'artifactory' +artifactory::db_automate: false +artifactory::download_filename: 'jfrog-artifactory-%s-%s-linux.tar.gz' +artifactory::download_url_oss: 'https://releases.jfrog.io/artifactory/bintray-artifactory/org/artifactory/oss/jfrog-artifactory-oss/%s/%s' +artifactory::download_url_pro: 'https://releases.jfrog.io/artifactory/artifactory-pro/org/artifactory/pro/jfrog-artifactory-pro/%s/%s' +artifactory::edition: 'oss' +artifactory::install_method: 'package' +artifactory::install_service_script: 'app/bin/installService.sh' +artifactory::manage_repo: true +artifactory::package_name: 'jfrog-artifactory-oss' +artifactory::package_name_pro: 'jfrog-artifactory-pro' +artifactory::package_version: 'present' +artifactory::root_password: 'password' +artifactory::service_name: 'artifactory' +artifactory::symlink_name: 'artifactory' +artifactory::use_temp_db_secrets: true diff --git a/hiera.yaml b/hiera.yaml index 545fff3..fc1fea6 100644 --- a/hiera.yaml +++ b/hiera.yaml @@ -6,16 +6,26 @@ defaults: # Used for any hierarchy level that omits these keys. data_hash: yaml_data # Use the built-in YAML backend. hierarchy: - - name: "osfamily/major release" - paths: - # Used to distinguish between Debian and Ubuntu - - "os/%{facts.os.name}/%{facts.os.release.major}.yaml" - - "os/%{facts.os.family}/%{facts.os.release.major}.yaml" - # Used for Solaris - - "os/%{facts.os.family}/%{facts.kernelrelease}.yaml" - - name: "osfamily" - paths: - - "os/%{facts.os.name}.yaml" - - "os/%{facts.os.family}.yaml" + - name: 'Set important hiera options' + path: "hiera_options.yaml" + + - name: 'Distribution Full Version' + path: '%{facts.os.name}-%{facts.os.release.full}.yaml' + + - name: 'Distribution Major Version' + path: '%{facts.os.name}-%{facts.os.release.major}.yaml' + + - name: 'Distribution Name' + path: '%{facts.os.name}.yaml' + + - name: 'OS Family Major Version' + path: '%{facts.os.family}-%{facts.os.release.major}-family.yaml' + + - name: 'OS Family' + path: '%{facts.os.family}-family.yaml' + + - name: 'OS Kernel' + path: '%{facts.kernel}.yaml' + - name: 'common' path: 'common.yaml' diff --git a/manifests/init.pp b/manifests/init.pp index 31adebc..b57c891 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -119,6 +119,9 @@ # @param root_password # Sets the root password for Puppet managed mysql database instance. # +# @param service_name +# Specifies the name of the Artifactory system service. +# # @param symlink_name # Controls the name of a version-independent symlink for the archive # installation. It will always point to the release specified by `$package_version`. @@ -139,51 +142,50 @@ # Sets the name of the yum repository. # class artifactory ( - Enum['oss', 'pro', 'enterprise'] $edition = 'oss', - Boolean $manage_repo = true, - Boolean $use_temp_db_secrets = true, - String $yum_name = 'bintray-jfrog-artifactory-rpms', - String $yum_baseurl = 'https://jfrog.bintray.com/artifactory-rpms', - String $yum_baseurl_pro = 'https://jfrog.bintray.com/artifactory-pro-rpms', - String $apt_baseurl = 'https://releases.jfrog.io/artifactory/artifactory-debs', - String $apt_baseurl_pro = 'https://releases.jfrog.io/artifactory/artifactory-pro-debs', - String $apt_key_id = 'A3D085F542F740BBD7E3A2846B219DCCD7639232', - String $apt_key_source = 'https://releases.jfrog.io/artifactory/api/gpg/key/public', - String $apt_repos = 'main', - String $package_name = 'jfrog-artifactory-oss', - String $package_name_pro = 'jfrog-artifactory-pro', - String $package_version = 'present', - String $artifactory_home = '/var/opt/jfrog/artifactory', - String $install_method = 'package', - String $download_filename = 'jfrog-artifactory-%s-%s-linux.tar.gz', - String $download_url_oss = 'https://releases.jfrog.io/artifactory/bintray-artifactory/org/artifactory/oss/jfrog-artifactory-oss/%s/%s', - String $download_url_pro = 'https://releases.jfrog.io/artifactory/artifactory-pro/org/artifactory/pro/jfrog-artifactory-pro/%s/%s', - String $symlink_name = 'artifactory', - String $install_service_script = 'app/bin/installService.sh', - Stdlib::Absolutepath $archive_install_dir = '/opt', - Stdlib::Absolutepath $archive_data_dir = '/opt/artifactory-data', - Optional[String] $config_owner = 'artifactory', - Optional[String] $config_group = 'artifactory', - Optional[String] $root_password = 'password', - Optional[String] $jdbc_driver_url = undef, - Optional[Enum['derby', 'mariadb', 'mssql', 'mysql', 'oracle', 'postgresql']] $db_type = undef, - Optional[String] $db_url = undef, - Optional[String] $db_username = undef, - Optional[String] $db_password = undef, - Optional[Boolean] $db_automate = false, + Stdlib::Absolutepath $archive_install_dir, + Stdlib::Absolutepath $archive_data_dir, + String $artifactory_home, + String $config_owner, + String $config_group, + Boolean $db_automate, + String $download_filename, + String $download_url_oss, + String $download_url_pro, + Enum['oss', 'pro', 'enterprise'] $edition, + String $install_method, + String $install_service_script, + Boolean $manage_repo, + String $package_name, + String $package_name_pro, + String $package_version, + String $root_password, + String $service_name, + String $symlink_name, + Boolean $use_temp_db_secrets, + Optional[String] $apt_baseurl = undef, + Optional[String] $apt_baseurl_pro = undef, + Optional[String] $apt_key_id = undef, + Optional[String] $apt_key_source = undef, + Optional[String] $apt_repos = undef, + Optional[String] $binary_provider_base_data_dir = undef, + Optional[String] $binary_provider_cache_dir = undef, + Optional[Integer] $binary_provider_cache_maxsize = undef, + Optional[Hash] $binary_provider_config_hash = undef, + Optional[String] $binary_provider_filesystem_dir = undef, Optional[Enum['filesystem', 'fullDb', 'cachedFS', 'fullDbDirect', 's3']] $binary_provider_type = undef, - Optional[Integer] $pool_max_active = undef, - Optional[Integer] $pool_max_idle = undef, - Optional[Integer] $binary_provider_cache_maxsize = undef, - Optional[String] $binary_provider_base_data_dir = undef, - Optional[String] $binary_provider_filesystem_dir = undef, - Optional[String] $binary_provider_cache_dir = undef, - Optional[Hash] $binary_provider_config_hash = undef, - Optional[String] $master_key = undef, - Optional[String] $license_key = undef, + Optional[String] $db_password = undef, + Optional[Enum['derby', 'mariadb', 'mssql', 'mysql', 'oracle', 'postgresql']] $db_type = undef, + Optional[String] $db_url = undef, + Optional[String] $db_username = undef, + Optional[String] $jdbc_driver_url = undef, + Optional[String] $license_key = undef, + Optional[String] $master_key = undef, + Optional[Integer] $pool_max_active = undef, + Optional[Integer] $pool_max_idle = undef, + Optional[String] $yum_baseurl = undef, + Optional[String] $yum_baseurl_pro = undef, + Optional[String] $yum_name = undef, ) { - $service_name = 'artifactory' - # Artifactory's data directory depends on the installation method. if ($install_method == 'package') { $data_directory = $artifactory_home