Skip to content

Commit

Permalink
Add a parameter to package mark hold
Browse files Browse the repository at this point in the history
  • Loading branch information
stjmt committed Jul 31, 2024
1 parent 543c582 commit 86d8f09
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 8 deletions.
17 changes: 13 additions & 4 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -508,6 +509,14 @@ Data type: `Integer`
For http, https, and ftp downloads, you may set how long the exec resource
may take.

##### <a name="-elasticsearch--package_hold"></a>`package_hold`

Data type: `Boolean`

Set to hold to tell Debian apt/Solaris pkg to hold the package version.

Default value: `false`

##### <a name="-elasticsearch--package_name"></a>`package_name`

Data type: `String`
Expand Down Expand Up @@ -3237,13 +3246,13 @@ Returns: `Any` String

### <a name="Elasticsearch--Multipath"></a>`Elasticsearch::Multipath`

The Elasticsearch::Multipath data type.
Elasticsearch datadir multipath type

Alias of `Variant[Array[Stdlib::Absolutepath], Stdlib::Absolutepath]`

### <a name="Elasticsearch--Status"></a>`Elasticsearch::Status`

The Elasticsearch::Status data type.
Elasticsearch service status type

Alias of `Enum['enabled', 'disabled', 'running', 'unmanaged']`

6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -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

Expand Down
16 changes: 13 additions & 3 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
13 changes: 13 additions & 0 deletions spec/classes/000_elasticsearch_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions types/multipath.pp
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Elasticsearch datadir multipath type
type Elasticsearch::Multipath = Variant[Array[Stdlib::Absolutepath], Stdlib::Absolutepath]
1 change: 1 addition & 0 deletions types/status.pp
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Elasticsearch service status type
type Elasticsearch::Status = Enum['enabled', 'disabled', 'running', 'unmanaged']

0 comments on commit 86d8f09

Please sign in to comment.