diff --git a/REFERENCE.md b/REFERENCE.md index 3ec71e538..03cfddab6 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -57,8 +57,8 @@ ### Data types -* [`Elasticsearch::Multipath`](#Elasticsearch--Multipath) -* [`Elasticsearch::Status`](#Elasticsearch--Status) +* [`Elasticsearch::Multipath`](#Elasticsearch--Multipath): Elasticsearch datadir multipath type +* [`Elasticsearch::Status`](#Elasticsearch--Status): Elasticsearch service status type ## Classes @@ -144,6 +144,7 @@ The following parameters are available in the `elasticsearch` class: * [`oss`](#-elasticsearch--oss) * [`package_dir`](#-elasticsearch--package_dir) * [`package_dl_timeout`](#-elasticsearch--package_dl_timeout) +* [`package_hold`](#-elasticsearch--package_hold) * [`package_name`](#-elasticsearch--package_name) * [`package_provider`](#-elasticsearch--package_provider) * [`package_url`](#-elasticsearch--package_url) @@ -508,6 +509,14 @@ Data type: `Integer` For http, https, and ftp downloads, you may set how long the exec resource may take. +##### `package_hold` + +Data type: `Boolean` + +Set to hold to tell Debian apt/Solaris pkg to hold the package version. + +Default value: `false` + ##### `package_name` Data type: `String` @@ -3237,13 +3246,13 @@ Returns: `Any` String ### `Elasticsearch::Multipath` -The Elasticsearch::Multipath data type. +Elasticsearch datadir multipath type Alias of `Variant[Array[Stdlib::Absolutepath], Stdlib::Absolutepath]` ### `Elasticsearch::Status` -The Elasticsearch::Status data type. +Elasticsearch service status type Alias of `Enum['enabled', 'disabled', 'running', 'unmanaged']` diff --git a/manifests/init.pp b/manifests/init.pp index e97ad1217..c245393e2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -184,6 +184,9 @@ # For http, https, and ftp downloads, you may set how long the exec resource # may take. # +# @param package_hold +# Set to hold to tell Debian apt/Solaris pkg to hold the package version. +# # @param package_name # Name Of the package to install. # @@ -430,12 +433,13 @@ String $default_logging_level = $logging_level, Optional[String] $keystore_password = undef, Optional[Stdlib::Absolutepath] $keystore_path = undef, + Stdlib::Filemode $logdir_mode = '2750', + Boolean $package_hold = false, Optional[Stdlib::Absolutepath] $private_key = undef, Enum['rsa','dsa','ec'] $private_key_type = 'rsa', Boolean $restart_config_change = $restart_on_change, Boolean $restart_package_change = $restart_on_change, Boolean $restart_plugin_change = $restart_on_change, - Stdlib::Filemode $logdir_mode = '2750', ) { #### Validate parameters diff --git a/manifests/package.pp b/manifests/package.pp index 3b956a943..93576854b 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -153,9 +153,19 @@ } if ($elasticsearch::package_provider == 'package') { - package { 'elasticsearch': - ensure => $package_ensure, - name => $elasticsearch::_package_name, + # You cannot use "mark" property while "ensure" is one of ["absent", "purged", "held"] + if $package_ensure in ['absent', 'purged', 'held'] { + package { 'elasticsearch': + ensure => $package_ensure, + name => $elasticsearch::_package_name, + } + } else { + # https://puppet.com/docs/puppet/7/types/package.html#package-attribute-mark + package { 'elasticsearch': + ensure => $package_ensure, + name => $elasticsearch::_package_name, + mark => ($elasticsearch::package_hold ? { true => 'hold', false => 'none', }), + } } exec { 'remove_plugin_dir': diff --git a/spec/classes/000_elasticsearch_init_spec.rb b/spec/classes/000_elasticsearch_init_spec.rb index 38e50426c..598e741f6 100644 --- a/spec/classes/000_elasticsearch_init_spec.rb +++ b/spec/classes/000_elasticsearch_init_spec.rb @@ -435,6 +435,19 @@ with(ensure: 'latest') } end + + describe 'with hold enabled' do + let(:params) do + default_params.merge( + package_hold: true + ) + end + + it { + expect(subject).to contain_package('elasticsearch'). + with(mark: 'hold') + } + end end describe 'running a different user' do diff --git a/types/multipath.pp b/types/multipath.pp index 63dea224d..83f966ff4 100644 --- a/types/multipath.pp +++ b/types/multipath.pp @@ -1 +1,2 @@ +# Elasticsearch datadir multipath type type Elasticsearch::Multipath = Variant[Array[Stdlib::Absolutepath], Stdlib::Absolutepath] diff --git a/types/status.pp b/types/status.pp index e31498bdb..6c13d755e 100644 --- a/types/status.pp +++ b/types/status.pp @@ -1 +1,2 @@ +# Elasticsearch service status type type Elasticsearch::Status = Enum['enabled', 'disabled', 'running', 'unmanaged']